PageRenderTime 19ms CodeModel.GetById 13ms app.highlight 3ms RepoModel.GetById 2ms app.codeStats 0ms

/Src/Dependencies/Boost/libs/iterator/doc/iterator_traits.rst

http://hadesmem.googlecode.com/
ReStructuredText | 98 lines | 77 code | 21 blank | 0 comment | 0 complexity | dba2f386289026b2725684ac03132e5a MD5 | raw file
 1.. Distributed under the Boost
 2.. Software License, Version 1.0. (See accompanying
 3.. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 4
 5+++++++++++++++++
 6 Iterator Traits
 7+++++++++++++++++
 8
 9:Author: David Abrahams
10:Contact: dave@boost-consulting.com
11:organization: `Boost Consulting`_
12:date: $Date: 2008-03-23 08:45:55 +1100 (Sun, 23 Mar 2008) $
13:copyright: Copyright David Abrahams 2004. 
14
15.. _`Boost Consulting`: http://www.boost-consulting.com
16
17:abstract: Header ``<boost/iterator/iterator_traits.hpp>`` provides
18  the ability to access an iterator's associated types using
19  MPL-compatible metafunctions_.
20
21.. _metafunctions: ../../mpl/doc/index.html#metafunctions
22
23Overview
24========
25
26``std::iterator_traits`` provides access to five associated types
27of any iterator: its ``value_type``, ``reference``, ``pointer``,
28``iterator_category``, and ``difference_type``.  Unfortunately,
29such a "multi-valued" traits template can be difficult to use in a
30metaprogramming context.  ``<boost/iterator/iterator_traits.hpp>``
31provides access to these types using a standard metafunctions_.
32
33Summary
34=======
35
36Header ``<boost/iterator/iterator_traits.hpp>``::
37
38  template <class Iterator>
39  struct iterator_value
40  {
41      typedef typename 
42        std::iterator_traits<Iterator>::value_type 
43      type;
44  };
45
46  template <class Iterator>
47  struct iterator_reference
48  {
49      typedef typename 
50        std::iterator_traits<Iterator>::reference
51      type;
52  };
53
54
55  template <class Iterator>
56  struct iterator_pointer
57  {
58      typedef typename 
59        std::iterator_traits<Iterator>::pointer 
60      type;
61  };
62
63  template <class Iterator>
64  struct iterator_difference
65  {
66      typedef typename
67        detail::iterator_traits<Iterator>::difference_type
68      type;
69  };
70
71  template <class Iterator>
72  struct iterator_category
73  {
74      typedef typename
75        detail::iterator_traits<Iterator>::iterator_category
76      type;
77  };
78
79Broken Compiler Notes
80=====================
81
82Because of workarounds in Boost, you may find that these
83metafunctions_ actually work better than the facilities provided by
84your compiler's standard library.
85
86On compilers that don't support partial specialization, such as
87Microsoft Visual C++ 6.0 or 7.0, you may need to manually invoke
88BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION_ on the
89``value_type`` of pointers that are passed to these metafunctions.
90
91Because of bugs in the implementation of GCC-2.9x, the name of
92``iterator_category`` is changed to ``iterator_category_`` on that
93compiler.  A macro, ``BOOST_ITERATOR_CATEGORY``, that expands to
94either ``iterator_category`` or ``iterator_category_``, as
95appropriate to the platform, is provided for portability.
96
97.. _BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION: ../../type_traits/index.html#transformations
98