py::builtins::range¶
Defined in <pypp/builtins/range.hpp>
template <class type>
class range;
Class for holding a range of values.
py::builtins::range holds a range of values. The range is
specified by three value:
start: The start value of the range.
stop: The end value of the range (exclusive).
step: The difference between values.
Warning
Although range support iterators, it’s iterators don’t
support operator -> as objects are constructed on demand.
It’s iterators also don’t return any references to object, they
return the object.
Template parameters¶
type: The type of values.
Members types¶
The type of values |
|
The type of iterators |
|
The type of constant iterators |
|
The type of reverse iterators |
|
The type of constant reverse iterators |
Members functions¶
Constructs a range |
|
Assigns a range to the range |
Value access
Accesses value at specified index |
|
Returns a slice of the range |
|
Acceses the first value |
|
Acceses the last value |
Capacity
Returns the size of the range |
Iterators
Returns an iterator to the beginning |
|
Returns an iterator to the end |
|
Returns a reverse iterator to the beginning |
|
Returns a reverse iterator to the end |
Observers
Returns the start value of the range |
|
Returns the stop value of the range |
|
Returns the step value of the range |
Lookup
Returns the count of a value in the range |
|
Returns the index of a value in the range |
|
Finds and returns an iterator to a value in the range |
Modifiers
Swaps the range with another |
Non-member functions¶
Compares two ranges lexicographically |
|
Specializes the py::builtins::operator ->* (py::builtins::in) algorithm |
|
Specializes the |
Example¶
#include <pypp/builtins/range.hpp>
#include <pypp/builtins/list.hpp>
#include <pypp/builtins/print.hpp>
int main()
{
py::range<int> nums(10);
py::print(py::list(nums));
}
Output:
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}