std::swap (py::builtins::range) (specialization)

template <class type>
constexpr void swap(
    py::builtins::range<type>& lhs,
    py::builtins::range<type>& rhs
) noexcept(noexcept(lhs.swap(rhs)));

Swaps a range with another range.

Tip

Equivalent to:

lhs.swap(rhs);

Parameter

lhs: A range.

rhs: Another range.

Complexity

Constant.

Example

#include <pypp/builtins/range.hpp>
#include <pypp/builtins/print.hpp>

int main()
{
    py::range<int> nums1(1, 10);
    py::range<int> nums2(5);

    std::swap(nums1, nums2);
    py::print(nums1.stop());
}

Output:

5