omni::detail::PointerIterator
Defined in omni/detail/PointerIterator.h
- 
template<typename TPointer, typename TContainer>
 class PointerIterator
- This iterator adapter wraps a pointer type into a class. It does not change the semantics of any operations from the fundamental logic of pointers. There are no bounds checks, there is no additional safety. - // This is meant to be used on contiguous containers where returning a pointer from @c begin and @c end would be // inappropriate. template <typename T> class MyContainer { public: using iterator = detail::PointerIterator<T*, MyContainer>; using const_iterator = detail::PointerIterator<T const*, MyContainer>; // ... iterator begin() { return iterator{data()}; } }; - Template Parameters
- TPointer – The pointer to base this wrapper on. The underlying value type of the pointer can be const-qualified. 
- TContainer – The container type this iterator iterates over. This is useful to make types distinct, even in cases where - TPointerwould be identical; for example, a- stringvs a- vector<char>. This is allowed to be- voidfor cases where there is no underlying container.
 
 - Public Types - 
using value_type = typename underlying_traits_type::value_type
- The underlying value that dereferencing this iterator returns. Note that this is not const-qualified; the - const_iteratorfor a container will still return- T.
 - 
using reference = typename underlying_traits_type::reference
- The reference type dereferencing this iterator returns. This is const-qualified, so - iteratorfor a container will return- T&and- const_iteratorwill return- const T&.
 - 
using pointer = typename underlying_traits_type::pointer
- The underlying pointer type - operator->()returns. This is const-qualified, so- iteratorfor a container will return- T*and- const_iteratorwill return- const T*.
 - 
using difference_type = typename underlying_traits_type::difference_type
- The type used to represent the distance between two iterators. This will always be - std::ptrdiff_t.
 - 
using iterator_category = typename underlying_traits_type::iterator_category
- The category of this iterator. This will always be - std::random_access_iterator_tag.
 - Public Functions - 
inline constexpr PointerIterator() noexcept
- Default construction of a pointer-iterator results in an iterator pointing to - nullptr.
 - 
inline explicit constexpr PointerIterator(pointer src) noexcept
- Create an iterator from src pointer. 
 - 
PointerIterator(const PointerIterator&) = default
- Instances are trivially copy-constructible. 
 - 
PointerIterator(PointerIterator&&) = default
- Instances are trivially move-constructible. 
 - 
PointerIterator &operator=(const PointerIterator&) = default
- Instances are trivially copyable. 
 - 
PointerIterator &operator=(PointerIterator&&) = default
- Instances are trivially movable. 
 - 
~PointerIterator() = default
- Instances are trivially destructible. 
 - 
template<typename UPointer, typename = std::enable_if_t<!std::is_same<TPointer, UPointer>::value && std::is_convertible<std::remove_reference_t<typename PointerIterator<UPointer, TContainer>::reference> (*)[], std::remove_reference_t<reference> (*)[]>::value>>
 inline constexpr PointerIterator(const PointerIterator<UPointer, TContainer> &src) noexcept
- Converting constructor to allow conversion from a non-const iterator type to a const iterator type. Generally, this allows a - TContainer::iteratorto become a- TContainer::const_iterator.- This constructor is only enabled if: - The - TContainerfor the two types is the same.
- The - TPointeris different from- UPointer(there is a conversion which needs to occur).
- A pointer to an array of the src const-qualified - value_type(aka- remove_reference_t<reference>) is convertible to an array of this const-qualified- value_type. This restricts conversion of iterators from a derived to a base class pointer type.
 
 - 
inline constexpr reference operator[](difference_type idx) const noexcept
- Get the value at offset idx from this iterator. Negative values are supported to reference behind this instance. 
 - 
inline constexpr PointerIterator &operator++() noexcept
- Move the iterator forward by one. 
 - 
inline constexpr PointerIterator operator++(int) noexcept
- Move the iterator forward by one, but return the previous position. 
 - 
inline constexpr PointerIterator &operator--() noexcept
- Move the iterator backwards by one. 
 - 
inline constexpr PointerIterator operator--(int) noexcept
- Move the iterator backwards by one, but return the previous position. 
 - 
inline constexpr PointerIterator &operator+=(difference_type dist) noexcept
- Move the iterator forward by dist. 
 - 
inline constexpr PointerIterator operator+(difference_type dist) const noexcept
- Get a new iterator pointing dist elements forward from this one. 
 - 
inline constexpr PointerIterator &operator-=(difference_type dist) noexcept
- Move the iterator backwards by dist. 
 - 
inline constexpr PointerIterator operator-(difference_type dist) const noexcept
- Get a new iterator pointing dist elements backwards from this one.