template<typename T>
py::Range struct

Python-like range implementation.

Template parameters
T The numeric type for the range values

Represents a sequence of numbers from start to stop (exclusive), similar to Python's range() function.

Public functions

auto begin() const -> iterator -> auto constexpr
Get iterator to the beginning of the range.
auto end() const -> iterator -> auto constexpr
Get iterator to the end of the range.
auto empty() const -> bool -> auto constexpr
Check if the range is empty.
auto size() const -> size_t -> auto constexpr
Get the size of the range.
auto operator[](size_t n) const -> T -> auto constexpr
Get element at index.
auto contains(T n) const noexcept -> bool -> auto constexpr
Check if the range contains a value.

Function documentation

template<typename T>
auto py::Range<T>::begin() const -> iterator constexpr

Get iterator to the beginning of the range.

Returns iterator Iterator to the beginning

Returns an iterator pointing to the start value of the range.

template<typename T>
auto py::Range<T>::end() const -> iterator constexpr

Get iterator to the end of the range.

Returns iterator Iterator past the last element

Returns an iterator pointing past the last element in the range.

template<typename T>
auto py::Range<T>::empty() const -> bool constexpr

Check if the range is empty.

Returns true if the range is empty, false otherwise

Returns true if the range has no elements (start equals stop).

template<typename T>
auto py::Range<T>::size() const -> size_t constexpr

Get the size of the range.

Returns size_t Number of elements in the range

Returns the number of elements in the range.

template<typename T>
auto py::Range<T>::operator[](size_t n) const -> T constexpr

Get element at index.

Parameters
in The index
Returns T The value at the index

Returns the value at the specified index in the range.

template<typename T>
auto py::Range<T>::contains(T n) const noexcept -> bool constexpr

Check if the range contains a value.

Parameters
in The value to check
Returns true if the range contains the value, false otherwise