xentara-utils v2.0.4
The Xentara Utility Library
Loading...
Searching...
No Matches
xentara::utils::core::ContiguousIterator< Base, Container > Class Template Reference

A wrapper around an iterator type that turns it into a fully featured contiguous iterator. More...

#include <xentara/utils/core/ContiguousIterator.hpp>

Public Types

using iterator_type = Base
 The base iterator type.
 
using value_type = typename std::iterator_traits< Base >::value_type
 The element type.
 
using difference_type = typename std::iterator_traits< Base >::difference_type
 The type used for distances.
 
using reference = typename std::iterator_traits< Base >::reference
 A reference to an element.
 
using pointer = typename std::iterator_traits< Base >::pointer
 A pointer to an element.
 
using iterator_concept = std::contiguous_iterator_tag
 The iterator concept.
 
using iterator_category = typename std::iterator_traits< Base >::iterator_category
 The iterator category, for use in pre-C++20 code.
 

Public Member Functions

constexpr ContiguousIterator () noexcept=default
 Default constructor.
 
internal constexpr ContiguousIterator (const Base &position) noexcept
 Constructor for a specific position.
 
constexpr ContiguousIterator (const typename Container::iterator &iterator) noexcept
 Conversion constructor for a mutable iterator belonging to the same type of container.
 
constexpr auto operator== (const ContiguousIterator &) const -> bool=default
 Equality operator.
 
constexpr auto operator<=> (const ContiguousIterator &) const -> std::compare_three_way_result_t< pointer >=default
 Three-Way-Comparison operator.
 
constexpr auto operator++ () noexcept -> ContiguousIterator &
 Pre-increment operator.
 
constexpr auto operator++ (int) noexcept -> ContiguousIterator
 Post-increment operator.
 
constexpr auto operator-- () noexcept -> ContiguousIterator &
 Pre-decrement operator.
 
constexpr auto operator-- (int) noexcept -> ContiguousIterator
 Post-decrement operator.
 
constexpr auto operator+= (difference_type offset) noexcept -> ContiguousIterator &
 Addition assignment operator.
 
constexpr auto operator-= (difference_type offset) noexcept -> ContiguousIterator &
 Subtraction assignment operator.
 
constexpr auto operator* () const noexcept -> reference
 Indirection operator.
 
constexpr auto operator-> () const noexcept -> pointer
 Member access operator.
 
constexpr auto operator[] (difference_type offset) const noexcept -> reference
 Subscript operator.
 
constexpr auto base () const noexcept -> const Base &
 Returns the base iterator.
 

Detailed Description

template<typename Base, typename Container = void>
class xentara::utils::core::ContiguousIterator< Base, Container >

A wrapper around an iterator type that turns it into a fully featured contiguous iterator.

This template can be used to turn a pointer like type into a fully fletched iterator.

Template Parameters
BaseThe base iterator type that should be wrapped. Must satisfy the named requirement LegacyContiguousIterator.
ContainerThe container type the iterator belongs to, or void for a genertic iterator. If you specify a container, then the ContiguousIterator must be either Container::iterator or Container::const_iterator

Member Typedef Documentation

◆ difference_type

template<typename Base , typename Container = void>
using xentara::utils::core::ContiguousIterator< Base, Container >::difference_type = typename std::iterator_traits<Base>::difference_type

The type used for distances.

◆ iterator_category

template<typename Base , typename Container = void>
using xentara::utils::core::ContiguousIterator< Base, Container >::iterator_category = typename std::iterator_traits<Base>::iterator_category

The iterator category, for use in pre-C++20 code.

◆ iterator_concept

template<typename Base , typename Container = void>
using xentara::utils::core::ContiguousIterator< Base, Container >::iterator_concept = std::contiguous_iterator_tag

The iterator concept.

◆ iterator_type

template<typename Base , typename Container = void>
using xentara::utils::core::ContiguousIterator< Base, Container >::iterator_type = Base

The base iterator type.

◆ pointer

template<typename Base , typename Container = void>
using xentara::utils::core::ContiguousIterator< Base, Container >::pointer = typename std::iterator_traits<Base>::pointer

A pointer to an element.

◆ reference

template<typename Base , typename Container = void>
using xentara::utils::core::ContiguousIterator< Base, Container >::reference = typename std::iterator_traits<Base>::reference

A reference to an element.

◆ value_type

template<typename Base , typename Container = void>
using xentara::utils::core::ContiguousIterator< Base, Container >::value_type = typename std::iterator_traits<Base>::value_type

The element type.

Constructor & Destructor Documentation

◆ ContiguousIterator() [1/3]

template<typename Base , typename Container = void>
constexpr xentara::utils::core::ContiguousIterator< Base, Container >::ContiguousIterator ( )
constexprdefaultnoexcept

Default constructor.

This constructor creates an iterator pointing to nullptr

◆ ContiguousIterator() [2/3]

template<typename Base , typename Container = void>
internal constexpr xentara::utils::core::ContiguousIterator< Base, Container >::ContiguousIterator ( const Base &  position)
explicitconstexprnoexcept

Constructor for a specific position.

◆ ContiguousIterator() [3/3]

template<typename Base , typename Container = void>
constexpr xentara::utils::core::ContiguousIterator< Base, Container >::ContiguousIterator ( const typename Container::iterator &  iterator)
constexprnoexcept

Conversion constructor for a mutable iterator belonging to the same type of container.

Creates a const iterator that points to the same position as a mutable iterator

Member Function Documentation

◆ base()

template<typename Base , typename Container = void>
constexpr auto xentara::utils::core::ContiguousIterator< Base, Container >::base ( ) const -> const Base&
constexprnoexcept

Returns the base iterator.

Returns
A base iterator to the current position

◆ operator*()

template<typename Base , typename Container = void>
constexpr auto xentara::utils::core::ContiguousIterator< Base, Container >::operator* ( ) const -> reference
constexprnoexcept

Indirection operator.

Note
Must not be called on the past-the-end iterator.
Returns
A reference to the object at the current position.

◆ operator++() [1/2]

template<typename Base , typename Container = void>
constexpr auto xentara::utils::core::ContiguousIterator< Base, Container >::operator++ ( ) -> ContiguousIterator &
constexprnoexcept

Pre-increment operator.

Moves the iterator forward by one position.

◆ operator++() [2/2]

template<typename Base , typename Container = void>
constexpr auto xentara::utils::core::ContiguousIterator< Base, Container >::operator++ ( int  ) -> ContiguousIterator
constexprnoexcept

Post-increment operator.

Moves the iterator forward by one position.

◆ operator+=()

template<typename Base , typename Container = void>
constexpr auto xentara::utils::core::ContiguousIterator< Base, Container >::operator+= ( difference_type  offset) -> ContiguousIterator &
constexprnoexcept

Addition assignment operator.

Moves the iterator forward by an offset. If the offset it negative, the iterator moves backward.

◆ operator--() [1/2]

template<typename Base , typename Container = void>
constexpr auto xentara::utils::core::ContiguousIterator< Base, Container >::operator-- ( ) -> ContiguousIterator &
constexprnoexcept

Pre-decrement operator.

Moves the iterator back by one position.

◆ operator--() [2/2]

template<typename Base , typename Container = void>
constexpr auto xentara::utils::core::ContiguousIterator< Base, Container >::operator-- ( int  ) -> ContiguousIterator
constexprnoexcept

Post-decrement operator.

Moves the iterator back by one position.

◆ operator-=()

template<typename Base , typename Container = void>
constexpr auto xentara::utils::core::ContiguousIterator< Base, Container >::operator-= ( difference_type  offset) -> ContiguousIterator &
constexprnoexcept

Subtraction assignment operator.

Moves the iterator backward by an offset. If the offset it negative, the iterator moves forward.

◆ operator->()

template<typename Base , typename Container = void>
constexpr auto xentara::utils::core::ContiguousIterator< Base, Container >::operator-> ( ) const -> pointer
constexprnoexcept

Member access operator.

Gives access to a member of the object at the current position.

Note
Must not be called on the past-the-end iterator.

◆ operator<=>()

template<typename Base , typename Container = void>
constexpr auto xentara::utils::core::ContiguousIterator< Base, Container >::operator<=> ( const ContiguousIterator< Base, Container > &  ) const -> std::compare_three_way_result_t< pointer >=default
constexprdefault

Three-Way-Comparison operator.

Compares the position of the two iterators

◆ operator==()

template<typename Base , typename Container = void>
constexpr auto xentara::utils::core::ContiguousIterator< Base, Container >::operator== ( const ContiguousIterator< Base, Container > &  ) const -> bool=default
constexprdefault

Equality operator.

Compares the position of the two iterators

◆ operator[]()

template<typename Base , typename Container = void>
constexpr auto xentara::utils::core::ContiguousIterator< Base, Container >::operator[] ( difference_type  offset) const -> reference
constexprnoexcept

Subscript operator.

Returns a reference to an object at a certain offset

Parameters
offsetThe offset. can be positive or negative.
Returns
A reference to the object at the given offset