2 #ifndef BOOST_MPL_MAP_AUX_AT_IMPL_HPP_INCLUDED
\r
3 #define BOOST_MPL_MAP_AUX_AT_IMPL_HPP_INCLUDED
\r
5 // Copyright Aleksey Gurtovoy 2003-2004
\r
6 // Copyright David Abrahams 2003-2004
\r
8 // Distributed under the Boost Software License, Version 1.0.
\r
9 // (See accompanying file LICENSE_1_0.txt or copy at
\r
10 // http://www.boost.org/LICENSE_1_0.txt)
\r
12 // See http://www.boost.org/libs/mpl for documentation.
\r
14 // $Id: at_impl.hpp 49267 2008-10-11 06:19:02Z agurtovoy $
\r
15 // $Date: 2008-10-11 02:19:02 -0400 (Sat, 11 Oct 2008) $
\r
16 // $Revision: 49267 $
\r
18 #include <boost/mpl/at_fwd.hpp>
\r
19 #include <boost/mpl/long.hpp>
\r
20 #include <boost/mpl/map/aux_/tag.hpp>
\r
21 #include <boost/mpl/aux_/order_impl.hpp>
\r
22 #include <boost/mpl/aux_/overload_names.hpp>
\r
23 #include <boost/mpl/aux_/type_wrapper.hpp>
\r
24 #include <boost/mpl/aux_/ptr_to_ref.hpp>
\r
25 #include <boost/mpl/aux_/static_cast.hpp>
\r
26 #include <boost/mpl/aux_/config/typeof.hpp>
\r
27 #include <boost/mpl/aux_/config/ctps.hpp>
\r
29 #if !defined(BOOST_MPL_CFG_TYPEOF_BASED_SEQUENCES)
\r
30 # include <boost/mpl/eval_if.hpp>
\r
31 # include <boost/mpl/pair.hpp>
\r
32 # include <boost/mpl/void.hpp>
\r
33 # include <boost/mpl/aux_/config/static_constant.hpp>
\r
36 namespace boost { namespace mpl {
\r
38 #if defined(BOOST_MPL_CFG_TYPEOF_BASED_SEQUENCES)
\r
40 template< typename Map, typename Key >
\r
43 typedef aux::type_wrapper<Key> key_;
\r
44 typedef __typeof__( BOOST_MPL_AUX_OVERLOAD_CALL_VALUE_BY_KEY(
\r
46 , BOOST_MPL_AUX_STATIC_CAST(key_*, 0)
\r
51 struct at_impl< aux::map_tag >
\r
53 template< typename Map, typename Key > struct apply
\r
54 : aux::wrapped_type< typename m_at<
\r
62 // agurt 31/jan/04: two-step implementation for the sake of GCC 3.x
\r
63 template< typename Map, long order >
\r
64 struct item_by_order_impl
\r
66 typedef __typeof__( BOOST_MPL_AUX_OVERLOAD_CALL_ITEM_BY_ORDER(
\r
68 , BOOST_MPL_AUX_STATIC_CAST(long_<order>*, 0)
\r
72 template< typename Map, long order >
\r
73 struct item_by_order
\r
74 : aux::wrapped_type<
\r
75 typename item_by_order_impl<Map,order>::type
\r
80 #else // BOOST_MPL_CFG_TYPEOF_BASED_SEQUENCES
\r
82 # if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
\r
84 template< typename Map, long n > struct m_at
\r
91 template< long n > struct m_at_impl
\r
93 template< typename Map > struct result_
\r
99 template< typename Map, long n > struct m_at
\r
101 typedef typename m_at_impl<n>::result_<Map>::type type;
\r
108 struct at_impl< aux::map_tag >
\r
110 template< typename Map, typename Key > struct apply
\r
112 typedef typename m_at< Map, (x_order_impl<Map,Key>::value - 2) >::type item_;
\r
113 typedef typename eval_if<
\r
121 template< typename Map, long order > struct is_item_masked
\r
123 BOOST_STATIC_CONSTANT(bool, value =
\r
124 sizeof( BOOST_MPL_AUX_OVERLOAD_CALL_IS_MASKED(
\r
126 , BOOST_MPL_AUX_STATIC_CAST(long_<order>*, 0)
\r
127 ) ) == sizeof(aux::yes_tag)
\r
131 template< typename Map, long order > struct item_by_order
\r
133 typedef typename eval_if_c<
\r
134 is_item_masked<Map,order>::value
\r
136 , m_at<Map,(order - 2)>
\r
144 #endif // BOOST_MPL_SET_AUX_AT_IMPL_HPP_INCLUDED
\r