Flow
Documentation for the Flow C++ Library
Loading...
Searching...
No Matches
flow::IntegralIterator< T > Class Template Reference

An iterator that can iterate through a range of integer. Useful when the search space is too big to fit into a container. More...

#include <flow_integral_iterator.h>

Public Types

using value_type = T
using difference_type = std::ptrdiff_t
using reference = T
using pointer = void
using iterator_category = std::random_access_iterator_tag

Public Member Functions

constexpr IntegralIterator (T value) noexcept
constexpr reference operator* () const noexcept
constexpr IntegralIteratoroperator++ () noexcept
constexpr IntegralIterator operator++ (int) noexcept
constexpr IntegralIteratoroperator-- () noexcept
constexpr IntegralIterator operator-- (int) noexcept
constexpr IntegralIteratoroperator+= (difference_type n) noexcept
constexpr IntegralIteratoroperator-= (difference_type n) noexcept
constexpr reference operator[] (difference_type n) const noexcept
constexpr difference_type operator- (const IntegralIterator &rhs) const noexcept
constexpr auto operator<=> (const IntegralIterator &) const =default

Private Attributes

value_

Friends

void swap (IntegralIterator &lhs, IntegralIterator &rhs) noexcept

Detailed Description

template<std::integral T>
class flow::IntegralIterator< T >

An iterator that can iterate through a range of integer. Useful when the search space is too big to fit into a container.

Definition at line 10 of file flow_integral_iterator.h.

Member Typedef Documentation

◆ difference_type

template<std::integral T>
using flow::IntegralIterator< T >::difference_type = std::ptrdiff_t

Definition at line 15 of file flow_integral_iterator.h.

◆ iterator_category

template<std::integral T>
using flow::IntegralIterator< T >::iterator_category = std::random_access_iterator_tag

Definition at line 18 of file flow_integral_iterator.h.

◆ pointer

template<std::integral T>
using flow::IntegralIterator< T >::pointer = void

Definition at line 17 of file flow_integral_iterator.h.

◆ reference

template<std::integral T>
using flow::IntegralIterator< T >::reference = T

Definition at line 16 of file flow_integral_iterator.h.

◆ value_type

template<std::integral T>
using flow::IntegralIterator< T >::value_type = T

Definition at line 14 of file flow_integral_iterator.h.

Constructor & Destructor Documentation

◆ IntegralIterator()

template<std::integral T>
flow::IntegralIterator< T >::IntegralIterator ( T value)
inlineexplicitconstexprnoexcept

Definition at line 20 of file flow_integral_iterator.h.

20: value_(value) {}
An iterator that can iterate through a range of integer. Useful when the search space is too big to f...

Referenced by operator++(), operator++(), operator+=(), operator-(), operator--(), operator--(), operator-=(), operator<=>(), and swap.

Member Function Documentation

◆ operator*()

template<std::integral T>
reference flow::IntegralIterator< T >::operator* ( ) const
inlineconstexprnoexcept

Definition at line 22 of file flow_integral_iterator.h.

22 {
23 return value_;
24 }

References value_.

◆ operator++() [1/2]

template<std::integral T>
IntegralIterator & flow::IntegralIterator< T >::operator++ ( )
inlineconstexprnoexcept

Definition at line 26 of file flow_integral_iterator.h.

26 {
27 ++value_;
28 return *this;
29 }

References IntegralIterator(), and value_.

◆ operator++() [2/2]

template<std::integral T>
IntegralIterator flow::IntegralIterator< T >::operator++ ( int )
inlineconstexprnoexcept

Definition at line 31 of file flow_integral_iterator.h.

31 {
32 IntegralIterator tmp = *this;
33 ++*this;
34 return tmp;
35 }
constexpr IntegralIterator(T value) noexcept

References IntegralIterator().

◆ operator+=()

template<std::integral T>
IntegralIterator & flow::IntegralIterator< T >::operator+= ( difference_type n)
inlineconstexprnoexcept

Definition at line 48 of file flow_integral_iterator.h.

48 {
49 value_ += static_cast<T>(n);
50 return *this;
51 }

References IntegralIterator(), and value_.

◆ operator-()

template<std::integral T>
difference_type flow::IntegralIterator< T >::operator- ( const IntegralIterator< T > & rhs) const
inlineconstexprnoexcept

Definition at line 62 of file flow_integral_iterator.h.

62 {
63 return static_cast<difference_type>(value_) - static_cast<difference_type>(rhs.value_);
64 }

References IntegralIterator(), and value_.

◆ operator--() [1/2]

template<std::integral T>
IntegralIterator & flow::IntegralIterator< T >::operator-- ( )
inlineconstexprnoexcept

Definition at line 37 of file flow_integral_iterator.h.

37 {
38 --value_;
39 return *this;
40 }

References IntegralIterator(), and value_.

◆ operator--() [2/2]

template<std::integral T>
IntegralIterator flow::IntegralIterator< T >::operator-- ( int )
inlineconstexprnoexcept

Definition at line 42 of file flow_integral_iterator.h.

42 {
43 IntegralIterator tmp = *this;
44 --*this;
45 return tmp;
46 }

References IntegralIterator().

◆ operator-=()

template<std::integral T>
IntegralIterator & flow::IntegralIterator< T >::operator-= ( difference_type n)
inlineconstexprnoexcept

Definition at line 53 of file flow_integral_iterator.h.

53 {
54 value_ -= static_cast<T>(n);
55 return *this;
56 }

References IntegralIterator(), and value_.

◆ operator<=>()

template<std::integral T>
auto flow::IntegralIterator< T >::operator<=> ( const IntegralIterator< T > & ) const
constexprdefault

References IntegralIterator().

◆ operator[]()

template<std::integral T>
reference flow::IntegralIterator< T >::operator[] ( difference_type n) const
inlineconstexprnoexcept

Definition at line 58 of file flow_integral_iterator.h.

58 {
59 return value_ + static_cast<reference>(n);
60 }

References value_.

◆ swap

template<std::integral T>
void swap ( IntegralIterator< T > & lhs,
IntegralIterator< T > & rhs )
friend

Definition at line 68 of file flow_integral_iterator.h.

68 {
69 using std::swap;
71 }
friend void swap(IntegralIterator &lhs, IntegralIterator &rhs) noexcept

References IntegralIterator(), and swap.

Referenced by swap.

Member Data Documentation

◆ value_

template<std::integral T>
T flow::IntegralIterator< T >::value_
private

The documentation for this class was generated from the following file: