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