1 
2 #ifndef BOOST_MPL_MAP_AUX_ITEM_HPP_INCLUDED
3 #define BOOST_MPL_MAP_AUX_ITEM_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 // $Id$
15 // $Date$
16 // $Revision$
17 
18 #include <boost/mpl/void.hpp>
19 #include <boost/mpl/pair.hpp>
20 #include <boost/mpl/long.hpp>
21 #include <boost/mpl/next.hpp>
22 #include <boost/mpl/prior.hpp>
23 #include <boost/mpl/map/aux_/map0.hpp>
24 #include <boost/mpl/aux_/order_impl.hpp>
25 #include <boost/mpl/aux_/yes_no.hpp>
26 #include <boost/mpl/aux_/type_wrapper.hpp>
27 #include <boost/mpl/aux_/config/arrays.hpp>
28 #include <boost/mpl/aux_/config/typeof.hpp>
29 #include <boost/mpl/aux_/config/ctps.hpp>
30 
31 
32 namespace boost { namespace mpl {
33 
34 #if defined(BOOST_MPL_CFG_TYPEOF_BASED_SEQUENCES)
35 
36 template< typename Key, typename T, typename Base >
37 struct m_item
38     : Base
39 {
40     typedef Key         key_;
41     typedef pair<Key,T> item;
42     typedef Base        base;
43     typedef m_item      type;
44 
45     typedef typename next< typename Base::size >::type  size;
46     typedef typename next< typename Base::order >::type order;
47 
48 #if defined(BOOST_MPL_CFG_NO_DEPENDENT_ARRAY_TYPES)
49     typedef typename aux::weighted_tag<BOOST_MPL_AUX_MSVC_VALUE_WKND(order)::value>::type order_tag_;
50 #else
51     typedef char (&order_tag_)[BOOST_MPL_AUX_MSVC_VALUE_WKND(order)::value];
52 #endif
53 
54     BOOST_MPL_AUX_MAP_OVERLOAD( aux::type_wrapper<T>, VALUE_BY_KEY, m_item, aux::type_wrapper<Key>* );
55     BOOST_MPL_AUX_MAP_OVERLOAD( aux::type_wrapper<item>, ITEM_BY_ORDER, m_item, order* );
56     BOOST_MPL_AUX_MAP_OVERLOAD( order_tag_, ORDER_BY_KEY, m_item, aux::type_wrapper<Key>* );
57 };
58 
59 
60 template< typename Key, typename Base >
61 struct m_mask
62     : Base
63 {
64     typedef void_   key_;
65     typedef Base    base;
66     typedef m_mask  type;
67 
68     typedef typename prior< typename Base::size >::type  size;
69     typedef typename x_order_impl<Base,Key>::type key_order_;
70 
71     BOOST_MPL_AUX_MAP_OVERLOAD( aux::type_wrapper<void_>, VALUE_BY_KEY, m_mask, aux::type_wrapper<Key>* );
72     BOOST_MPL_AUX_MAP_OVERLOAD( aux::type_wrapper<void_>, ITEM_BY_ORDER, m_mask, key_order_* );
73 };
74 
75 #else // BOOST_MPL_CFG_TYPEOF_BASED_SEQUENCES
76 
77 
78 #   if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
79 
80 template< long n, typename Key, typename T, typename Base >
81 struct m_item;
82 
83 #   else
84 
85 template< long n >
86 struct m_item_impl
87 {
88     template< typename Key, typename T, typename Base >
89     struct result_;
90 };
91 
92 template< long n, typename Key, typename T, typename Base >
93 struct m_item
94     : m_item_impl<n>::result_<Key,T,Base>
95 {
96 };
97 
98 
99 #   endif
100 
101 
102 template< typename Key, typename T, typename Base >
103 struct m_item_
104     : Base
105 {
106     typedef Key     key_;
107     typedef Base    base;
108     typedef m_item_ type;
109 
110     typedef typename next< typename Base::size >::type  size;
111     typedef typename next< typename Base::order >::type order;
112 
113 #if defined(BOOST_MPL_CFG_NO_DEPENDENT_ARRAY_TYPES)
114     typedef typename aux::weighted_tag<BOOST_MPL_AUX_MSVC_VALUE_WKND(order)::value>::type order_tag_;
115 #else
116     typedef char (&order_tag_)[BOOST_MPL_AUX_MSVC_VALUE_WKND(order)::value];
117 #endif
118 
119     BOOST_MPL_AUX_MAP_OVERLOAD( order_tag_, ORDER_BY_KEY, m_item_, aux::type_wrapper<Key>* );
120 };
121 
122 template< typename Key, typename Base >
123 struct m_mask
124     : Base
125 {
126     typedef void_   key_;
127     typedef Base    base;
128     typedef m_mask  type;
129 
130     typedef typename prior< typename Base::size >::type  size;
131     typedef typename x_order_impl<Base,Key>::type key_order_;
132 
133     BOOST_MPL_AUX_MAP_OVERLOAD( aux::no_tag, ORDER_BY_KEY, m_mask, aux::type_wrapper<Key>* );
134     BOOST_MPL_AUX_MAP_OVERLOAD( aux::yes_tag, IS_MASKED, m_mask, key_order_* );
135 };
136 
137 #endif // BOOST_MPL_CFG_TYPEOF_BASED_SEQUENCES
138 
139 }}
140 
141 #endif // BOOST_MPL_MAP_AUX_ITEM_HPP_INCLUDED
142