Chris@16: Chris@16: #if !defined(BOOST_PP_IS_ITERATING) Chris@16: Chris@16: ///// header body Chris@16: Chris@16: #ifndef BOOST_MPL_INHERIT_HPP_INCLUDED Chris@16: #define BOOST_MPL_INHERIT_HPP_INCLUDED Chris@16: Chris@16: // Copyright Aleksey Gurtovoy 2001-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: #if !defined(BOOST_MPL_PREPROCESSING_MODE) Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: #endif Chris@16: Chris@16: #include Chris@16: Chris@16: #if !defined(BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS) \ Chris@16: && !defined(BOOST_MPL_PREPROCESSING_MODE) Chris@16: Chris@16: # define BOOST_MPL_PREPROCESSED_HEADER inherit.hpp Chris@16: # include Chris@16: Chris@16: #else Chris@16: Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: Chris@16: namespace boost { namespace mpl { Chris@16: Chris@16: // 'inherit' metafunction; returns an unspecified class type Chris@16: // produced by public derivation from all metafunction's parameters Chris@16: // (T1,T2,..,Tn), except the parameters of 'empty_base' class type; Chris@16: // regardless the position and number of 'empty_base' parameters in the Chris@16: // metafunction's argument list, derivation from them is always a no-op; Chris@16: // for instance: Chris@16: // inherit::type == her Chris@16: // inherit::type == struct unspecified : her, my {}; Chris@16: // inherit::type == her Chris@16: // inherit::type == her Chris@16: // inherit::type == struct unspecified : her, my {}; Chris@16: // inherit::type == empty_base Chris@16: Chris@16: #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) Chris@16: Chris@16: template< Chris@16: typename BOOST_MPL_AUX_NA_PARAM(T1) Chris@16: , typename BOOST_MPL_AUX_NA_PARAM(T2) Chris@16: > Chris@16: struct inherit2 Chris@16: : T1, T2 Chris@16: { Chris@16: typedef inherit2 type; Chris@16: BOOST_MPL_AUX_LAMBDA_SUPPORT(2, inherit2, (T1,T2)) Chris@16: }; Chris@16: Chris@16: template< typename T1 > Chris@16: struct inherit2 Chris@16: { Chris@16: typedef T1 type; Chris@16: BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(2, inherit2, (T1,empty_base)) Chris@16: }; Chris@16: Chris@16: template< typename T2 > Chris@16: struct inherit2 Chris@16: { Chris@16: typedef T2 type; Chris@16: BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(2, inherit2, (empty_base,T2)) Chris@16: }; Chris@16: Chris@16: // needed to disambiguate the previous two in case when both Chris@16: // T1 and T2 == empty_base Chris@16: template<> Chris@16: struct inherit2 Chris@16: { Chris@16: typedef empty_base type; Chris@16: BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(2, inherit2, (empty_base,empty_base)) Chris@16: }; Chris@16: Chris@16: #else Chris@16: Chris@16: namespace aux { Chris@16: Chris@16: template< bool C1, bool C2 > Chris@16: struct inherit2_impl Chris@16: { Chris@16: template< typename Derived, typename T1, typename T2 > struct result_ Chris@16: : T1, T2 Chris@16: { Chris@16: typedef Derived type_; Chris@16: }; Chris@16: }; Chris@16: Chris@16: template<> Chris@16: struct inherit2_impl Chris@16: { Chris@16: template< typename Derived, typename T1, typename T2 > struct result_ Chris@16: : T1 Chris@16: { Chris@16: typedef T1 type_; Chris@16: }; Chris@16: }; Chris@16: Chris@16: template<> Chris@16: struct inherit2_impl Chris@16: { Chris@16: template< typename Derived, typename T1, typename T2 > struct result_ Chris@16: : T2 Chris@16: { Chris@16: typedef T2 type_; Chris@16: }; Chris@16: }; Chris@16: Chris@16: template<> Chris@16: struct inherit2_impl Chris@16: { Chris@16: template< typename Derived, typename T1, typename T2 > struct result_ Chris@16: { Chris@16: typedef T1 type_; Chris@16: }; Chris@16: }; Chris@16: Chris@16: } // namespace aux Chris@16: Chris@16: template< Chris@16: typename BOOST_MPL_AUX_NA_PARAM(T1) Chris@16: , typename BOOST_MPL_AUX_NA_PARAM(T2) Chris@16: > Chris@16: struct inherit2 Chris@16: : aux::inherit2_impl< Chris@16: is_empty_base::value Chris@16: , is_empty_base::value Chris@16: >::template result_< inherit2,T1,T2 > Chris@16: { Chris@16: typedef typename inherit2::type_ type; Chris@16: BOOST_MPL_AUX_LAMBDA_SUPPORT(2, inherit2, (T1,T2)) Chris@16: }; Chris@16: Chris@16: #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION Chris@16: Chris@16: BOOST_MPL_AUX_NA_SPEC(2, inherit2) Chris@16: Chris@16: #define BOOST_PP_ITERATION_PARAMS_1 \ Chris@16: (3,(3, BOOST_MPL_LIMIT_METAFUNCTION_ARITY, )) Chris@16: #include BOOST_PP_ITERATE() Chris@16: Chris@16: }} Chris@16: Chris@16: #endif // BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS Chris@16: #endif // BOOST_MPL_INHERIT_HPP_INCLUDED Chris@16: Chris@16: ///// iteration Chris@16: Chris@16: #else Chris@16: #define n_ BOOST_PP_FRAME_ITERATION(1) Chris@16: Chris@16: template< Chris@16: BOOST_MPL_PP_DEFAULT_PARAMS(n_, typename T, na) Chris@16: > Chris@16: struct BOOST_PP_CAT(inherit,n_) Chris@16: : inherit2< Chris@16: typename BOOST_PP_CAT(inherit,BOOST_PP_DEC(n_))< Chris@16: BOOST_MPL_PP_PARAMS(BOOST_PP_DEC(n_), T) Chris@16: >::type Chris@16: , BOOST_PP_CAT(T,n_) Chris@16: > Chris@16: { Chris@16: BOOST_MPL_AUX_LAMBDA_SUPPORT( Chris@16: n_ Chris@16: , BOOST_PP_CAT(inherit,n_) Chris@16: , (BOOST_MPL_PP_PARAMS(n_, T)) Chris@16: ) Chris@16: }; Chris@16: Chris@16: BOOST_MPL_AUX_NA_SPEC(n_, BOOST_PP_CAT(inherit,n_)) Chris@16: Chris@16: #if n_ == BOOST_MPL_LIMIT_METAFUNCTION_ARITY Chris@16: /// primary template Chris@16: template< Chris@16: BOOST_MPL_PP_DEFAULT_PARAMS(n_, typename T, empty_base) Chris@16: > Chris@16: struct inherit Chris@16: : BOOST_PP_CAT(inherit,n_) Chris@16: { Chris@16: }; Chris@16: Chris@16: // 'na' specialization Chris@16: template<> Chris@16: struct inherit< BOOST_MPL_PP_ENUM(5, na) > Chris@16: { Chris@16: template< Chris@16: #if !defined(BOOST_MPL_CFG_NO_DEFAULT_PARAMETERS_IN_NESTED_TEMPLATES) Chris@16: BOOST_MPL_PP_DEFAULT_PARAMS(n_, typename T, empty_base) Chris@16: #else Chris@16: BOOST_MPL_PP_PARAMS(n_, typename T) Chris@16: #endif Chris@16: > Chris@16: struct apply Chris@16: : inherit< BOOST_MPL_PP_PARAMS(n_, T) > Chris@16: { Chris@16: }; Chris@16: }; Chris@16: Chris@16: BOOST_MPL_AUX_NA_SPEC_LAMBDA(n_, inherit) Chris@16: BOOST_MPL_AUX_NA_SPEC_ARITY(n_, inherit) Chris@16: BOOST_MPL_AUX_NA_SPEC_TEMPLATE_ARITY(n_, n_, inherit) Chris@16: #endif Chris@16: Chris@16: #undef n_ Chris@16: #endif // BOOST_PP_IS_ITERATING