kblib 0.2.3
General utilities library for modern C++
|
A range generator, similar to Python 3's range(). More...
#include <kblib/iterators.h>
Classes | |
struct | iterator |
A helper struct which acts as an iterator for the range elements, as they are generated on the fly. More... | |
Public Member Functions | |
constexpr | range_t (Value min_, Value max_, Delta step_=1) |
2- and 3-argument constructor. Explicitly specify start, end, and optionally the step amount. More... | |
constexpr | range_t (Value max_) |
1-argument constructor. Start is implicitly zero and step is 1 or -1, depending on the sign of max. More... | |
constexpr auto | begin () const noexcept -> iterator |
Returns an iterator to the beginning of the range. More... | |
constexpr auto | end () const noexcept -> iterator |
Return an iterator to the end of the range. More... | |
constexpr auto | size () const noexcept -> std::size_t |
Returns the distance between start() and stop(). More... | |
constexpr auto | empty () const noexcept -> bool |
Query whether the range will generate any elements. More... | |
template<typename Integral > | |
constexpr auto | operator[] (Integral x) const noexcept -> decltype(begin()[x]) |
constexpr auto | lesser () const noexcept(nothrow_copyable) -> Value |
constexpr auto | greater () const noexcept(nothrow_copyable) -> Value |
template<typename Container , enable_if_t< is_linear_container_v< Container > and std::is_constructible< Container, iterator, iterator >::value > * = nullptr> | |
operator Container () const noexcept(noexcept(Container(std::declval< iterator >(), std::declval< iterator >()))) | |
Returns a linear container whose elements are this range. More... | |
template<typename Container , enable_if_t< is_setlike_v< Container > and std::is_constructible< Container, iterator, iterator >::value > * = nullptr> | |
operator Container () const noexcept(noexcept(Container(std::declval< iterator >(), std::declval< iterator >()))) | |
Returns a setlike container whose elements are this range. More... | |
Friends | |
constexpr auto | begin (const range_t &r) noexcept -> iterator |
Returns an iterator to the beginning of the range. More... | |
constexpr auto | end (const range_t &r) noexcept -> iterator |
Return an iterator to the end of the range. More... | |
constexpr auto | size (const range_t &r) noexcept -> std::size_t |
Returns the distance between start() and stop(). More... | |
constexpr friend auto | operator== (range_t l, range_t r) noexcept -> bool |
Compare l and r for equality. More... | |
constexpr friend auto | operator!= (range_t l, range_t r) noexcept -> bool |
Compare l and r for inequality. More... | |
A range generator, similar to Python 3's range().
Generates a half-open range, [min, max).
Value | The type of elements in the range. Must support comparison (equality and relational) and subtraction, but does not strictly need to be numeric. Must be copyable. Must be value-initializable. Notably, RandomAccessIterators are valid Value types. |
Delta | A type used to mutate Value values. std::declval<Value>() + std::declval<Delta>() must be a valid expression and must return type Value. Delta must be implicitly constructible and assignable from, as well as comparable to, int. |
Definition at line 222 of file iterators.h.
|
inlineconstexpr |
2- and 3-argument constructor. Explicitly specify start, end, and optionally the step amount.
min_ | The first value in the range. |
max_ | The end of the range. |
step_ | The difference between values in the range. |
Definition at line 240 of file iterators.h.
|
inlineconstexpr |
1-argument constructor. Start is implicitly zero and step is 1 or -1, depending on the sign of max.
max | The end of the range. |
Definition at line 252 of file iterators.h.
|
inlineconstexprnoexcept |
Returns an iterator to the beginning of the range.
Definition at line 377 of file iterators.h.
|
inlineconstexprnoexcept |
Query whether the range will generate any elements.
Definition at line 413 of file iterators.h.
|
inlineconstexprnoexcept |
Return an iterator to the end of the range.
Definition at line 381 of file iterators.h.
|
inlineconstexprnoexcept |
Definition at line 425 of file iterators.h.
|
inlineconstexprnoexcept |
Definition at line 421 of file iterators.h.
|
inlineexplicitnoexcept |
Returns a linear container whose elements are this range.
Definition at line 437 of file iterators.h.
|
inlineexplicitnoexcept |
Returns a setlike container whose elements are this range.
Definition at line 451 of file iterators.h.
|
inlineconstexprnoexcept |
Definition at line 416 of file iterators.h.
|
inlineconstexprnoexcept |
Returns the distance between start() and stop().
Definition at line 386 of file iterators.h.
|
friend |
Returns an iterator to the beginning of the range.
Definition at line 393 of file iterators.h.
|
friend |
Return an iterator to the end of the range.
Definition at line 399 of file iterators.h.
|
friend |
Compare l and r for inequality.
Ranges are equal when they generate identical ranges.
Definition at line 472 of file iterators.h.
|
friend |
Compare l and r for equality.
Ranges are equal when they generate identical ranges.
Definition at line 462 of file iterators.h.
|
friend |
Returns the distance between start() and stop().
Definition at line 406 of file iterators.h.