Range< Iterator, Sentinel > Class Template Reference
|
CPP API
|
mio::Range< Iterator, Sentinel > Class Template Reference
A range of items defined by two iterators. More...
#include <stl_util.h>
Public Types | |
| using | const_iterator = iterator |
| using | const_reverse_iterator = std::reverse_iterator< const_iterator > |
| using | iterator = Iterator |
| using | reference = typename std::iterator_traits< iterator >::reference |
| using | reverse_iterator = std::reverse_iterator< iterator > |
| using | value_type = typename std::iterator_traits< iterator >::value_type |
Public Member Functions | |
| Iterator | begin () const |
| Get an iterator to the start of the range, pointing at the first element of the range. More... | |
| Sentinel | end () const |
| Get an iterator at the end of the range, pointing to one element after the last in the range. More... | |
| Range (Iterator begin, Sentinel end) | |
| Directly construct a Range from two iterators. More... | |
| template<class I , class S > | |
| Range (std::pair< I, S > iterator_pair) | |
| Construct a Range from an std::pair of iterators. More... | |
| template<class T > | |
| Range (T &&range) | |
| Construct a Range from another range. More... | |
Public Attributes | |
| reference front() const requires std Sentinel | m_sentinel |
| Get a reference to the first element in the range. More... | |
Detailed Description
template<class Iterator, class Sentinel = Iterator>
class mio::Range< Iterator, Sentinel >
A range of items defined by two iterators.
Models an immutable random access range, e.g. a piece of a vector. Immutable means that elements can not be added or removed, while the elements themselves can be modified, if the iterators that make up the range allow it.
- Template Parameters
-
Iterator An iterator to the beginning of the range. Sentinel A sentinel to the end of the range. Defaults to the same type as Iterator.
Member Typedef Documentation
◆ const_iterator
template<class Iterator , class Sentinel = Iterator>
| using mio::Range< Iterator, Sentinel >::const_iterator = iterator |
◆ const_reverse_iterator
template<class Iterator , class Sentinel = Iterator>
| using mio::Range< Iterator, Sentinel >::const_reverse_iterator = std::reverse_iterator<const_iterator> |
◆ iterator
template<class Iterator , class Sentinel = Iterator>
| using mio::Range< Iterator, Sentinel >::iterator = Iterator |
◆ reference
template<class Iterator , class Sentinel = Iterator>
| using mio::Range< Iterator, Sentinel >::reference = typename std::iterator_traits<iterator>::reference |
◆ reverse_iterator
template<class Iterator , class Sentinel = Iterator>
| using mio::Range< Iterator, Sentinel >::reverse_iterator = std::reverse_iterator<iterator> |
◆ value_type
template<class Iterator , class Sentinel = Iterator>
| using mio::Range< Iterator, Sentinel >::value_type = typename std::iterator_traits<iterator>::value_type |
Constructor & Destructor Documentation
◆ Range() [1/3]
template<class Iterator , class Sentinel = Iterator>
|
inline |
Directly construct a Range from two iterators.
◆ Range() [2/3]
template<class Iterator , class Sentinel = Iterator>
template<class T >
|
inline |
Construct a Range from another range.
◆ Range() [3/3]
template<class Iterator , class Sentinel = Iterator>
template<class I , class S >
|
inline |
Construct a Range from an std::pair of iterators.
Member Function Documentation
◆ begin()
template<class Iterator , class Sentinel = Iterator>
|
inline |
Get an iterator to the start of the range, pointing at the first element of the range.
◆ end()
template<class Iterator , class Sentinel = Iterator>
|
inline |
Get an iterator at the end of the range, pointing to one element after the last in the range.
Member Data Documentation
◆ m_sentinel
template<class Iterator , class Sentinel = Iterator>
| reference front () const requires std Sentinel mio::Range< Iterator, Sentinel >::m_sentinel |
Get a reference to the first element in the range.
Access operator.
- Parameters
-
[in] index An index into the range.
- Returns
- Returns a reference to the element at the given index. Has constant complexity if random access iterator, linear otherwise
Generated by