Library of Assembled Shared Sources
lass::stde::index_iterator_t< ContainerType, ValueType, PointerType, ReferenceType, SizeType, DifferenceType > Class Template Reference

iterator adaptor to access members. More...

#include <index_iterator.h>

Inheritance diagram for lass::stde::index_iterator_t< ContainerType, ValueType, PointerType, ReferenceType, SizeType, DifferenceType >:

Detailed Description

template<typename ContainerType, typename ValueType = typename ContainerType::value_type, typename PointerType = typename ContainerType::pointer, typename ReferenceType = typename ContainerType::reference, typename SizeType = size_t, typename DifferenceType = std::ptrdiff_t>
class lass::stde::index_iterator_t< ContainerType, ValueType, PointerType, ReferenceType, SizeType, DifferenceType >

iterator adaptor to access members.

A prime example is to iterate over the keys or values in a std::map.
The value_type of the map's iterator is a std::pair of key and value.
first_accessor_t is an accessor that will access the first element of the pair, and combined with index_iterator_t it allows you to directly iterate over just the keys of the map.
A helper function first_iterator is provided to easily adapt a map's iterator:

// prints spam, ham, eggs
std::map<std::string, int> map;
map["spam"] = 1;
map["ham"] = 2;
map["eggs"] = 3;
std::copy(
first_iterator(map.begin()),
first_iterator(map.end()),
std::ostream_iterator<std::string>(std::cout, ", "));
Template Parameters
Iteratorthe iterator type of the original sequence. In the example above, this would be std::map<std::string, int>::iterator
Accessorfunctor type that takes an Iterator as argument and returns a reference to the accessed member. Accessor shall also define value_type, reference and pointer. An example is first_accessor_t

Definition at line 94 of file index_iterator.h.


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