Chris@16: Chris@16: #ifndef BOOST_MPL_MAP_AUX_AT_IMPL_HPP_INCLUDED Chris@16: #define BOOST_MPL_MAP_AUX_AT_IMPL_HPP_INCLUDED Chris@16: Chris@16: // Copyright Aleksey Gurtovoy 2003-2004 Chris@16: // Copyright David Abrahams 2003-2004 Chris@16: // Chris@16: // Distributed under the Boost Software License, Version 1.0. Chris@16: // (See accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: // Chris@16: // See http://www.boost.org/libs/mpl for documentation. Chris@16: Chris@101: // $Id$ Chris@101: // $Date$ Chris@101: // $Revision$ Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: #if !defined(BOOST_MPL_CFG_TYPEOF_BASED_SEQUENCES) Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: #endif Chris@16: Chris@16: namespace boost { namespace mpl { Chris@16: Chris@16: #if defined(BOOST_MPL_CFG_TYPEOF_BASED_SEQUENCES) Chris@16: Chris@16: template< typename Map, typename Key > Chris@16: struct m_at Chris@16: { Chris@16: typedef aux::type_wrapper key_; Chris@16: typedef __typeof__( BOOST_MPL_AUX_OVERLOAD_CALL_VALUE_BY_KEY( Chris@16: Map Chris@16: , BOOST_MPL_AUX_STATIC_CAST(key_*, 0) Chris@16: ) ) type; Chris@16: }; Chris@16: Chris@16: template<> Chris@16: struct at_impl< aux::map_tag > Chris@16: { Chris@16: template< typename Map, typename Key > struct apply Chris@16: : aux::wrapped_type< typename m_at< Chris@16: Map Chris@16: , Key Chris@16: >::type > Chris@16: { Chris@16: }; Chris@16: }; Chris@16: Chris@16: // agurt 31/jan/04: two-step implementation for the sake of GCC 3.x Chris@16: template< typename Map, long order > Chris@16: struct item_by_order_impl Chris@16: { Chris@16: typedef __typeof__( BOOST_MPL_AUX_OVERLOAD_CALL_ITEM_BY_ORDER( Chris@16: Map Chris@16: , BOOST_MPL_AUX_STATIC_CAST(long_*, 0) Chris@16: ) ) type; Chris@16: }; Chris@16: Chris@16: template< typename Map, long order > Chris@16: struct item_by_order Chris@16: : aux::wrapped_type< Chris@16: typename item_by_order_impl::type Chris@16: > Chris@16: { Chris@16: }; Chris@16: Chris@16: #else // BOOST_MPL_CFG_TYPEOF_BASED_SEQUENCES Chris@16: Chris@16: # if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) Chris@16: Chris@16: template< typename Map, long n > struct m_at Chris@16: { Chris@16: typedef void_ type; Chris@16: }; Chris@16: Chris@16: # else Chris@16: Chris@16: template< long n > struct m_at_impl Chris@16: { Chris@16: template< typename Map > struct result_ Chris@16: { Chris@16: typedef void_ type; Chris@16: }; Chris@16: }; Chris@16: Chris@16: template< typename Map, long n > struct m_at Chris@16: { Chris@16: typedef typename m_at_impl::result_::type type; Chris@16: }; Chris@16: Chris@16: # endif Chris@16: Chris@16: Chris@16: template<> Chris@16: struct at_impl< aux::map_tag > Chris@16: { Chris@16: template< typename Map, typename Key > struct apply Chris@16: { Chris@16: typedef typename m_at< Map, (x_order_impl::value - 2) >::type item_; Chris@16: typedef typename eval_if< Chris@16: is_void_ Chris@16: , void_ Chris@16: , second Chris@16: >::type type; Chris@16: }; Chris@16: }; Chris@16: Chris@16: template< typename Map, long order > struct is_item_masked Chris@16: { Chris@16: BOOST_STATIC_CONSTANT(bool, value = Chris@16: sizeof( BOOST_MPL_AUX_OVERLOAD_CALL_IS_MASKED( Chris@16: Map Chris@16: , BOOST_MPL_AUX_STATIC_CAST(long_*, 0) Chris@16: ) ) == sizeof(aux::yes_tag) Chris@16: ); Chris@16: }; Chris@16: Chris@16: template< typename Map, long order > struct item_by_order Chris@16: { Chris@16: typedef typename eval_if_c< Chris@16: is_item_masked::value Chris@16: , void_ Chris@16: , m_at Chris@16: >::type type; Chris@16: }; Chris@16: Chris@16: #endif Chris@16: Chris@16: }} Chris@16: Chris@16: #endif // BOOST_MPL_SET_AUX_AT_IMPL_HPP_INCLUDED