source: NonGTP/Boost/boost/mpl/map/aux_/iterator.hpp @ 857

Revision 857, 3.8 KB checked in by igarcia, 19 years ago (diff)
RevLine 
[857]1
2#ifndef BOOST_MPL_MAP_AUX_ITERATOR_HPP_INCLUDED
3#define BOOST_MPL_MAP_AUX_ITERATOR_HPP_INCLUDED
4
5// Copyright Aleksey Gurtovoy 2003-2004
6// Copyright David Abrahams 2003-2004
7//
8// Distributed under the Boost Software License, Version 1.0.
9// (See accompanying file LICENSE_1_0.txt or copy at
10// http://www.boost.org/LICENSE_1_0.txt)
11//
12// See http://www.boost.org/libs/mpl for documentation.
13
14// $Source: /cvsroot/boost/boost/boost/mpl/map/aux_/iterator.hpp,v $
15// $Date: 2004/12/14 14:05:32 $
16// $Revision: 1.3 $
17
18#include <boost/mpl/map/aux_/map0.hpp>
19#include <boost/mpl/map/aux_/at_impl.hpp>
20#include <boost/mpl/map/aux_/tag.hpp>
21#include <boost/mpl/iterator_tags.hpp>
22#include <boost/mpl/if.hpp>
23#include <boost/mpl/next.hpp>
24#include <boost/mpl/deref.hpp>
25#include <boost/mpl/long.hpp>
26#include <boost/mpl/void.hpp>
27#include <boost/mpl/aux_/nttp_decl.hpp>
28#include <boost/mpl/aux_/config/ctps.hpp>
29
30namespace boost { namespace mpl {
31
32#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
33
34template<
35      typename Map
36    , long order
37    , long max_order
38    >
39struct next_order
40    : if_<
41          is_void_< typename item_by_order<Map,order>::type >
42        , next_order<Map,(order+1),max_order>
43        , long_<order>
44        >::type
45{
46};
47
48template<
49      typename Map
50    , long max_order
51    >
52struct next_order<Map,max_order,max_order>
53    : long_<max_order>
54{
55};
56
57
58template< typename Map, long order, long max_order >
59struct m_iter
60{
61    typedef forward_iterator_tag category;
62    typedef typename item_by_order<Map,order>::type type;
63};
64
65template< typename Map, long max_order >
66struct m_iter<Map,max_order,max_order>
67{
68    typedef forward_iterator_tag category;
69};
70
71
72template< typename Map, long order, long max_order >
73struct next< m_iter<Map,order,max_order> >
74{
75    typedef m_iter<
76          Map
77        , next_order<Map,order+1,max_order>::value
78        , max_order
79        > type;
80};
81
82template< typename Map, long max_order >
83struct next< m_iter<Map,max_order,max_order> >
84{
85};
86
87#else
88
89template<
90      typename Map
91    , BOOST_MPL_AUX_NTTP_DECL(long, order)
92    , BOOST_MPL_AUX_NTTP_DECL(long, max_order)
93    >
94struct next_order;
95
96template<
97      typename Map
98    , BOOST_MPL_AUX_NTTP_DECL(long, order)
99    , BOOST_MPL_AUX_NTTP_DECL(long, max_order)
100    >
101struct next_order_impl
102    : if_<
103          is_void_< typename item_by_order<Map,order>::type >
104        , next_order<Map,(order+1),max_order>
105        , long_<order>
106        >::type
107    {
108    };
109
110template<
111      typename Map
112    , BOOST_MPL_AUX_NTTP_DECL(long, order)
113    , BOOST_MPL_AUX_NTTP_DECL(long, max_order)
114    >
115struct next_order
116    : if_c<
117          (order != max_order)
118        , next_order_impl<Map,order,max_order>
119        , long_<order>
120        >::type
121{
122};
123
124
125template<
126      typename Map
127    , BOOST_MPL_AUX_NTTP_DECL(long, order)
128    , BOOST_MPL_AUX_NTTP_DECL(long, max_order)
129    >
130struct m_iter;
131
132struct m_iter_empty_base {};
133
134template<
135      typename Map
136    , BOOST_MPL_AUX_NTTP_DECL(long, order)
137    , BOOST_MPL_AUX_NTTP_DECL(long, max_order)
138    >
139struct m_iter_base
140{
141    typedef typename item_by_order<Map,order>::type type;
142   
143    typedef m_iter<
144          Map
145        , next_order<Map,order+1,max_order>::value
146        , max_order
147        > next;
148};
149
150template<
151      typename Map
152    , BOOST_MPL_AUX_NTTP_DECL(long, order)
153    , BOOST_MPL_AUX_NTTP_DECL(long, max_order)
154    >
155struct m_iter
156  : if_c<
157          (order == max_order)
158        , m_iter_empty_base
159        , m_iter_base<Map,order,max_order>
160        >::type
161{
162    typedef forward_iterator_tag category;
163};
164
165#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
166
167}}
168
169#endif // BOOST_MPL_MAP_AUX_ITERATOR_HPP_INCLUDED
Note: See TracBrowser for help on using the repository browser.