15#if __cpp_constexpr >= 201304
16# define CONSTEXPR14 constexpr
18# define CONSTEXPR14 inline
54 return this->i != other.i;
69 return this->i == other.i;
116 template <
typename T>
struct Range {
150 constexpr auto empty() const ->
bool {
return this->stop == this->
start; }
159 constexpr auto size() const ->
size_t {
160 return static_cast<size_t>(this->stop - this->
start);
172 return T(this->start + n);
181 constexpr auto contains(T n)
const noexcept ->
bool {
182 return !(n < this->
start) && n < this->
stop;
#define CONSTEXPR14
Definition fractions.hpp:18
Python-like utilities and data structures for C++.
Definition dict.hpp:18
CONSTEXPR14 auto range(T start, T stop) -> Range< T >
range(T start, T stop)
Definition range.hpp:198
Iterator for range-based sequences.
Definition range.hpp:31
T key_type
Definition range.hpp:38
std::input_iterator_tag iterator_category
Definition range.hpp:32
T value_type
Definition range.hpp:34
const T & const_reference
Definition range.hpp:37
CONSTEXPR14 auto operator*() const -> const_reference
Definition range.hpp:79
constexpr auto operator==(const RangeIterator &other) const -> bool
Equal to operator.
Definition range.hpp:68
T i
Definition range.hpp:40
CONSTEXPR14 auto operator++(int) -> RangeIterator
Post-increment operator.
Definition range.hpp:101
constexpr auto operator!=(const RangeIterator &other) const -> bool
Not equal to.
Definition range.hpp:53
std::ptrdiff_t difference_type
Definition range.hpp:33
CONSTEXPR14 auto operator++() -> RangeIterator &
Pre-increment operator.
Definition range.hpp:88
const T * pointer
Definition range.hpp:35
const T & reference
Definition range.hpp:36
Python-like range implementation.
Definition range.hpp:116
T value_type
Definition range.hpp:119
T start
Definition range.hpp:122
constexpr auto end() const -> iterator
Get iterator to the end of the range.
Definition range.hpp:141
T key_type
Definition range.hpp:120
constexpr auto contains(T n) const noexcept -> bool
Check if the range contains a value.
Definition range.hpp:181
constexpr auto begin() const -> iterator
Get iterator to the beginning of the range.
Definition range.hpp:132
constexpr auto size() const -> size_t
Get the size of the range.
Definition range.hpp:159
constexpr auto empty() const -> bool
Check if the range is empty.
Definition range.hpp:150
T stop
Definition range.hpp:123
constexpr auto operator[](size_t n) const -> T
Get element at index.
Definition range.hpp:171