Brian Silverman | 5962333 | 2018-08-04 23:36:56 -0700 | [diff] [blame^] | 1 | <?xml version="1.0" encoding="utf-8" ?> |
| 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 3 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> |
| 4 | <head> |
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| 6 | <meta name="generator" content="Docutils 0.11: http://docutils.sourceforge.net/" /> |
| 7 | <title>Iterator Traits</title> |
| 8 | <meta name="author" content="David Abrahams" /> |
| 9 | <meta name="organization" content="Boost Consulting" /> |
| 10 | <meta name="date" content="$Date$" /> |
| 11 | <meta name="copyright" content="Copyright David Abrahams 2004." /> |
| 12 | <link rel="stylesheet" href="../../../rst.css" type="text/css" /> |
| 13 | </head> |
| 14 | <body> |
| 15 | <div class="document" id="iterator-traits"> |
| 16 | <h1 class="title">Iterator Traits</h1> |
| 17 | <table class="docinfo" frame="void" rules="none"> |
| 18 | <col class="docinfo-name" /> |
| 19 | <col class="docinfo-content" /> |
| 20 | <tbody valign="top"> |
| 21 | <tr><th class="docinfo-name">Author:</th> |
| 22 | <td>David Abrahams</td></tr> |
| 23 | <tr><th class="docinfo-name">Contact:</th> |
| 24 | <td><a class="first last reference external" href="mailto:dave@boost-consulting.com">dave@boost-consulting.com</a></td></tr> |
| 25 | <tr><th class="docinfo-name">Organization:</th> |
| 26 | <td><a class="first last reference external" href="http://www.boost-consulting.com">Boost Consulting</a></td></tr> |
| 27 | <tr><th class="docinfo-name">Date:</th> |
| 28 | <td>$Date$</td></tr> |
| 29 | <tr><th class="docinfo-name">Copyright:</th> |
| 30 | <td>Copyright David Abrahams 2004.</td></tr> |
| 31 | </tbody> |
| 32 | </table> |
| 33 | <!-- Distributed under the Boost --> |
| 34 | <!-- Software License, Version 1.0. (See accompanying --> |
| 35 | <!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) --> |
| 36 | <table class="docutils field-list" frame="void" rules="none"> |
| 37 | <col class="field-name" /> |
| 38 | <col class="field-body" /> |
| 39 | <tbody valign="top"> |
| 40 | <tr class="field"><th class="field-name">abstract:</th><td class="field-body">Header <tt class="docutils literal"><boost/iterator/iterator_traits.hpp></tt> provides |
| 41 | the ability to access an iterator's associated types using |
| 42 | MPL-compatible <a class="reference external" href="../../mpl/doc/index.html#metafunctions">metafunctions</a>.</td> |
| 43 | </tr> |
| 44 | </tbody> |
| 45 | </table> |
| 46 | <div class="section" id="overview"> |
| 47 | <h1>Overview</h1> |
| 48 | <p><tt class="docutils literal"><span class="pre">std::iterator_traits</span></tt> provides access to five associated types |
| 49 | of any iterator: its <tt class="docutils literal">value_type</tt>, <tt class="docutils literal">reference</tt>, <tt class="docutils literal">pointer</tt>, |
| 50 | <tt class="docutils literal">iterator_category</tt>, and <tt class="docutils literal">difference_type</tt>. Unfortunately, |
| 51 | such a "multi-valued" traits template can be difficult to use in a |
| 52 | metaprogramming context. <tt class="docutils literal"><boost/iterator/iterator_traits.hpp></tt> |
| 53 | provides access to these types using a standard <a class="reference external" href="../../mpl/doc/index.html#metafunctions">metafunctions</a>.</p> |
| 54 | </div> |
| 55 | <div class="section" id="summary"> |
| 56 | <h1>Summary</h1> |
| 57 | <p>Header <tt class="docutils literal"><boost/iterator/iterator_traits.hpp></tt>:</p> |
| 58 | <pre class="literal-block"> |
| 59 | template <class Iterator> |
| 60 | struct iterator_value |
| 61 | { |
| 62 | typedef typename |
| 63 | std::iterator_traits<Iterator>::value_type |
| 64 | type; |
| 65 | }; |
| 66 | |
| 67 | template <class Iterator> |
| 68 | struct iterator_reference |
| 69 | { |
| 70 | typedef typename |
| 71 | std::iterator_traits<Iterator>::reference |
| 72 | type; |
| 73 | }; |
| 74 | |
| 75 | |
| 76 | template <class Iterator> |
| 77 | struct iterator_pointer |
| 78 | { |
| 79 | typedef typename |
| 80 | std::iterator_traits<Iterator>::pointer |
| 81 | type; |
| 82 | }; |
| 83 | |
| 84 | template <class Iterator> |
| 85 | struct iterator_difference |
| 86 | { |
| 87 | typedef typename |
| 88 | detail::iterator_traits<Iterator>::difference_type |
| 89 | type; |
| 90 | }; |
| 91 | |
| 92 | template <class Iterator> |
| 93 | struct iterator_category |
| 94 | { |
| 95 | typedef typename |
| 96 | detail::iterator_traits<Iterator>::iterator_category |
| 97 | type; |
| 98 | }; |
| 99 | </pre> |
| 100 | </div> |
| 101 | </div> |
| 102 | <div class="footer"> |
| 103 | <hr class="footer" /> |
| 104 | <a class="reference external" href="iterator_traits.rst">View document source</a>. |
| 105 | Generated by <a class="reference external" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference external" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source. |
| 106 | |
| 107 | </div> |
| 108 | </body> |
| 109 | </html> |