1.. Iterators/Iterator Metafunctions//iterator_category |60 2 3iterator_category 4================= 5 6Synopsis 7-------- 8 9.. parsed-literal:: 10 11 template< 12 typename Iterator 13 > 14 struct iterator_category 15 { 16 typedef typename Iterator::category type; 17 }; 18 19 20 21Description 22----------- 23 24Returns one of the following iterator category tags: 25 26* ``forward_iterator_tag`` 27* ``bidirectional_iterator_tag`` 28* ``random_access_iterator_tag`` 29 30 31Header 32------ 33 34.. parsed-literal:: 35 36 #include <boost/mpl/iterator_category.hpp> 37 #include <boost/mpl/iterator_tags.hpp> 38 39 40Parameters 41---------- 42 43+---------------+-----------------------+-------------------------------------------+ 44| Parameter | Requirement | Description | 45+===============+=======================+===========================================+ 46| ``Iterator`` | |Forward Iterator| | The iterator to obtain a category for. | 47+---------------+-----------------------+-------------------------------------------+ 48 49 50Expression semantics 51-------------------- 52 53For any |Forward Iterator|\ s ``iter``: 54 55 56.. parsed-literal:: 57 58 typedef iterator_category<iter>::type tag; 59 60:Return type: 61 |Integral Constant|. 62 63:Semantics: 64 ``tag`` is ``forward_iterator_tag`` if ``iter`` is a model of |Forward Iterator|, 65 ``bidirectional_iterator_tag`` if ``iter`` is a model of |Bidirectional Iterator|, 66 or ``random_access_iterator_tag`` if ``iter`` is a model of |Random Access Iterator|; 67 68:Postcondition: 69 ``forward_iterator_tag::value < bidirectional_iterator_tag::value``, 70 ``bidirectional_iterator_tag::value < random_access_iterator_tag::value``. 71 72 73Complexity 74---------- 75 76Amortized constant time. 77 78 79Example 80------- 81 82.. parsed-literal:: 83 84 template< typename Tag, typename Iterator > 85 struct algorithm_impl 86 { 87 // *O(n)* implementation 88 }; 89 90 template< typename Iterator > 91 struct algorithm_impl<random_access_iterator_tag,Iterator> 92 { 93 // *O(1)* implementation 94 }; 95 96 template< typename Iterator > 97 struct algorithm 98 : algorithm_impl< 99 iterator_category<Iterator>::type 100 , Iterator 101 > 102 { 103 }; 104 105 106 107See also 108-------- 109 110|Iterators|, |begin| / |end|, |advance|, |distance|, |next| 111 112 113.. copyright:: Copyright � 2001-2009 Aleksey Gurtovoy and David Abrahams 114 Distributed under the Boost Software License, Version 1.0. (See accompanying 115 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 116