C++ Boost

iterator_property_map<RandomAccessIterator, OffsetMap, T, R>

This property map is an adaptor that converts any random access iterator into a Lvalue Property Map. The OffsetMap type is responsible for converting key objects to integers that can be used as offsets with the random access iterator.

Example

template <typename T>
typename boost::property_traits<T>::value_type get_value_three(T m)
{
  return get(m, 3);
}

int main()
{
  typedef boost::identity_property_map id_map;  
  std::vector<int> fibo;
  
  fibo.push_back(1);
  fibo.push_back(1);
  fibo.push_back(2);
  fibo.push_back(3);
  fibo.push_back(5);
  fibo.push_back(8);
  fibo.push_back(13);
  
  boost::iterator_property_map< std::vector<int>::iterator, id_map> fibo_map(fibo.begin() + 2);

  std::cout << "The sixth fibonacci number is " << get_value_three(fibo_map) << std::endl;
  
  int primes[]={2,3,5,7,11,13,17};

  boost::iterator_property_map< int*, id_map, int, int&> prime_map(&primes[1]);

std::cout << "The fifth prime number is " << get_value_three(prime_map) <<std::endl; return 0; }

Where Defined

boost/property_map/property_map.hpp

Model Of

Lvalue Property Map

Template Parameters

ParameterDescriptionDefault
Iterator Must be a model of Random Access Iterator.  
OffsetMap Must be a model of Readable Property Map and the value type must be convertible to the difference type of the iterator.  
T The value type of the iterator. std::iterator_traits<RandomAccessIterator>::value_type
R The reference type of the iterator. std::iterator_traits<RandomAccessIterator>::reference

Members

In addition to the methods and functions required by Lvalue Property Map, this class has the following members.


property_traits<iterator_property_map>::value_type
This is the same type as std::iterator_traits<Iterator>::value_type.
iterator_property_map(Iterator i)
Constructor. The OffsetMap is default constructed.
iterator_property_map(Iterator i, OffsetMap m)
Constructor.
reference operator[](const key_type& v) const
The operator bracket for property access. The reference is from std::iterator_traits<Iterator> and the key_type is from boost::property_traits<OffsetMap>.

Non-Member functions


  template <class RAIter, class OffsetMap>
  iterator_property_map<RAIter, OffsetMap,
    typename std::iterator_traits<RAIter>::value_type,
    typename std::iterator_traits<RAIter>::reference
    >
  make_iterator_property_map(RAIter iter, OffsetMap omap)
A function for conveniently creating an iterator map.
  template <class RAIter, class OffsetMap, class ValueType>
  iterator_property_map<RAIter, OffsetMap,
    typename std::iterator_traits<RAIter>::value_type,
    typename std::iterator_traits<RAIter>::reference
    >
  make_iterator_property_map(RAIter iter, OffsetMap omap, ValueType dummy_arg)
Use this function instead of the 2-argument version if your compiler does not support partial specialization (like Visual C++).


Copyright © 2000-2012

Jeremy Siek, Univ.of Notre Dame (jsiek@osl.iu.edu)
Lie-Quan Lee, Univ.of Notre Dame (llee1@osl.iu.edu)
Andrew Lumsdaine, Univ.of Notre Dame (lums@osl.iu.edu)
Alex Hagen-Zanker