File indexing completed on 2025-01-18 09:41:43
0001
0002 #ifndef BOOST_MPL_MAP_AUX_AT_IMPL_HPP_INCLUDED
0003 #define BOOST_MPL_MAP_AUX_AT_IMPL_HPP_INCLUDED
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #include <boost/mpl/at_fwd.hpp>
0019 #include <boost/mpl/long.hpp>
0020 #include <boost/mpl/map/aux_/tag.hpp>
0021 #include <boost/mpl/aux_/order_impl.hpp>
0022 #include <boost/mpl/aux_/overload_names.hpp>
0023 #include <boost/mpl/aux_/type_wrapper.hpp>
0024 #include <boost/mpl/aux_/ptr_to_ref.hpp>
0025 #include <boost/mpl/aux_/static_cast.hpp>
0026 #include <boost/mpl/aux_/config/typeof.hpp>
0027 #include <boost/mpl/aux_/config/ctps.hpp>
0028
0029 #if !defined(BOOST_MPL_CFG_TYPEOF_BASED_SEQUENCES)
0030 # include <boost/mpl/eval_if.hpp>
0031 # include <boost/mpl/pair.hpp>
0032 # include <boost/mpl/void.hpp>
0033 # include <boost/mpl/aux_/config/static_constant.hpp>
0034 #endif
0035
0036 namespace boost { namespace mpl {
0037
0038 #if defined(BOOST_MPL_CFG_TYPEOF_BASED_SEQUENCES)
0039
0040 template< typename Map, typename Key >
0041 struct m_at
0042 {
0043 typedef aux::type_wrapper<Key> key_;
0044 typedef __typeof__( BOOST_MPL_AUX_OVERLOAD_CALL_VALUE_BY_KEY(
0045 Map
0046 , BOOST_MPL_AUX_STATIC_CAST(key_*, 0)
0047 ) ) type;
0048 };
0049
0050 template<>
0051 struct at_impl< aux::map_tag >
0052 {
0053 template< typename Map, typename Key > struct apply
0054 : aux::wrapped_type< typename m_at<
0055 Map
0056 , Key
0057 >::type >
0058 {
0059 };
0060 };
0061
0062
0063 template< typename Map, long order >
0064 struct item_by_order_impl
0065 {
0066 typedef __typeof__( BOOST_MPL_AUX_OVERLOAD_CALL_ITEM_BY_ORDER(
0067 Map
0068 , BOOST_MPL_AUX_STATIC_CAST(long_<order>*, 0)
0069 ) ) type;
0070 };
0071
0072 template< typename Map, long order >
0073 struct item_by_order
0074 : aux::wrapped_type<
0075 typename item_by_order_impl<Map,order>::type
0076 >
0077 {
0078 };
0079
0080 #else
0081
0082 # if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
0083
0084 template< typename Map, long n > struct m_at
0085 {
0086 typedef void_ type;
0087 };
0088
0089 # else
0090
0091 template< long n > struct m_at_impl
0092 {
0093 template< typename Map > struct result_
0094 {
0095 typedef void_ type;
0096 };
0097 };
0098
0099 template< typename Map, long n > struct m_at
0100 {
0101 typedef typename m_at_impl<n>::result_<Map>::type type;
0102 };
0103
0104 # endif
0105
0106
0107 template<>
0108 struct at_impl< aux::map_tag >
0109 {
0110 template< typename Map, typename Key > struct apply
0111 {
0112 typedef typename m_at< Map, (x_order_impl<Map,Key>::value - 2) >::type item_;
0113 typedef typename eval_if<
0114 is_void_<item_>
0115 , void_
0116 , second<item_>
0117 >::type type;
0118 };
0119 };
0120
0121 template< typename Map, long order > struct is_item_masked
0122 {
0123 BOOST_STATIC_CONSTANT(bool, value =
0124 sizeof( BOOST_MPL_AUX_OVERLOAD_CALL_IS_MASKED(
0125 Map
0126 , BOOST_MPL_AUX_STATIC_CAST(long_<order>*, 0)
0127 ) ) == sizeof(aux::yes_tag)
0128 );
0129 };
0130
0131 template< typename Map, long order > struct item_by_order
0132 {
0133 typedef typename eval_if_c<
0134 is_item_masked<Map,order>::value
0135 , void_
0136 , m_at<Map,(order - 2)>
0137 >::type type;
0138 };
0139
0140 #endif
0141
0142 }}
0143
0144 #endif