Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/graph/example/put-get-helper-eg.cpp @ 47

Last change on this file since 47 was 29, checked in by landauf, 16 years ago

updated boost from 1_33_1 to 1_34_1

File size: 1.8 KB
Line 
1//=======================================================================
2// Copyright 2001 Jeremy G. Siek, Andrew Lumsdaine, Lie-Quan Lee,
3//
4// Distributed under the Boost Software License, Version 1.0. (See
5// accompanying file LICENSE_1_0.txt or copy at
6// http://www.boost.org/LICENSE_1_0.txt)
7//=======================================================================
8#include <vector>
9#include <string>
10#include <boost/property_map.hpp>
11
12#ifdef BOOST_NO_STD_ITERATOR_TRAITS
13#error This examples requires a compiler that provides a working std::iterator_traits
14#endif
15
16
17namespace foo
18{
19  using namespace boost;
20    template < class RandomAccessIterator, class IndexMap >
21    class iterator_property_map:public boost::put_get_helper <
22    typename std::iterator_traits < RandomAccessIterator >::reference,
23    iterator_property_map < RandomAccessIterator, IndexMap > >
24  {
25  public:
26    typedef std::ptrdiff_t key_type;
27    typedef typename std::iterator_traits < RandomAccessIterator >::value_type
28      value_type;
29    typedef typename std::iterator_traits < RandomAccessIterator >::reference
30      reference;
31    typedef boost::lvalue_property_map_tag category;
32
33      iterator_property_map(RandomAccessIterator cc = RandomAccessIterator(),
34                            const IndexMap & _id =
35                            IndexMap()):iter(cc), index(_id)
36    {
37    }
38    reference operator[] (std::ptrdiff_t v) const
39    {
40      return *(iter + get(index, v));
41    }
42  protected:
43      RandomAccessIterator iter;
44    IndexMap index;
45  };
46
47}
48
49int
50main()
51{
52  typedef std::vector < std::string > vec_t;
53  typedef foo::iterator_property_map < vec_t::iterator,
54    boost::identity_property_map > pmap_t;
55  using namespace boost;
56  function_requires < Mutable_LvaluePropertyMapConcept < pmap_t, int > >();
57  return 0;
58}
Note: See TracBrowser for help on using the repository browser.