#include <genesis/utils/containers/deref_iterator.hpp>
Inherits BaseIterator.
Iterator class that exposes elements in a container of pointers.
This class can be used as an iterator into a container of pointers, in order to avoid double dereferencing of the elements:
std::vector<std::unique_ptr<T>> foo;
for( auto& it : foo ){
auto const baz = (*it)->bar;
}
This is cumbersome. By using this class, the double dereferencing is not needed. See Tree class for an exemplary usage of this technique.
Inspired by https://jonasdevlieghere.com/containers-of-unique-pointers/
Definition at line 60 of file deref_iterator.hpp.
Public Member Functions | |
| DereferenceIterator (BaseIterator const &other) | |
| reference | operator* () const |
| pointer | operator-> () const |
| reference | operator[] (difference_type n) const |
Public Types | |
| using | difference_type = typename BaseIterator::difference_type |
| using | pointer = value_type * |
| using | reference = value_type & |
| using | value_type = typename BaseIterator::value_type::element_type |
|
inline |
Definition at line 70 of file deref_iterator.hpp.
|
inline |
Definition at line 74 of file deref_iterator.hpp.
|
inline |
Definition at line 79 of file deref_iterator.hpp.
|
inline |
Definition at line 84 of file deref_iterator.hpp.
| using difference_type = typename BaseIterator::difference_type |
Definition at line 65 of file deref_iterator.hpp.
| using pointer = value_type * |
Definition at line 67 of file deref_iterator.hpp.
| using reference = value_type & |
Definition at line 68 of file deref_iterator.hpp.
| using value_type = typename BaseIterator::value_type::element_type |
Definition at line 64 of file deref_iterator.hpp.