• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1[section:iterator_traits Iterator Traits]
2
3`std::iterator_traits` provides access to five associated types
4of any iterator: its `value_type`, `reference`, `pointer`,
5`iterator_category`, and `difference_type`.  Unfortunately,
6such a "multi-valued" traits template can be difficult to use in a
7metaprogramming context.  `<boost/iterator/iterator_traits.hpp>`
8provides access to these types using a standard metafunctions_.
9
10[h2 Synopsis]
11
12Header `<boost/iterator/iterator_traits.hpp>`:
13
14  template <class Iterator>
15  struct iterator_value
16  {
17      typedef typename
18        std::iterator_traits<Iterator>::value_type
19      type;
20  };
21
22  template <class Iterator>
23  struct iterator_reference
24  {
25      typedef typename
26        std::iterator_traits<Iterator>::reference
27      type;
28  };
29
30  template <class Iterator>
31  struct iterator_pointer
32  {
33      typedef typename
34        std::iterator_traits<Iterator>::pointer
35      type;
36  };
37
38  template <class Iterator>
39  struct iterator_difference
40  {
41      typedef typename
42        detail::iterator_traits<Iterator>::difference_type
43      type;
44  };
45
46  template <class Iterator>
47  struct iterator_category
48  {
49      typedef typename
50        detail::iterator_traits<Iterator>::iterator_category
51      type;
52  };
53
54[endsect]
55