sl@0: sl@0: #if !defined(BOOST_PP_IS_ITERATING) sl@0: sl@0: ///// header body sl@0: sl@0: #ifndef BOOST_MPL_INHERIT_HPP_INCLUDED sl@0: #define BOOST_MPL_INHERIT_HPP_INCLUDED sl@0: sl@0: // Copyright Aleksey Gurtovoy 2001-2004 sl@0: // sl@0: // Distributed under the Boost Software License, Version 1.0. sl@0: // (See accompanying file LICENSE_1_0.txt or copy at sl@0: // http://www.boost.org/LICENSE_1_0.txt) sl@0: // sl@0: // See http://www.boost.org/libs/mpl for documentation. sl@0: sl@0: // $Source: /cvsroot/boost/boost/boost/mpl/inherit.hpp,v $ sl@0: // $Date: 2004/09/02 15:40:41 $ sl@0: // $Revision: 1.5 $ sl@0: sl@0: #if !defined(BOOST_MPL_PREPROCESSING_MODE) sl@0: # include sl@0: # include sl@0: # include sl@0: #endif sl@0: sl@0: #include sl@0: sl@0: #if !defined(BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS) \ sl@0: && !defined(BOOST_MPL_PREPROCESSING_MODE) sl@0: sl@0: # define BOOST_MPL_PREPROCESSED_HEADER inherit.hpp sl@0: # include sl@0: sl@0: #else sl@0: sl@0: # include sl@0: # include sl@0: # include sl@0: # include sl@0: # include sl@0: # include sl@0: sl@0: # include sl@0: # include sl@0: # include sl@0: sl@0: namespace boost { namespace mpl { sl@0: sl@0: // 'inherit' metafunction; returns an unspecified class type sl@0: // produced by public derivation from all metafunction's parameters sl@0: // (T1,T2,..,Tn), except the parameters of 'empty_base' class type; sl@0: // regardless the position and number of 'empty_base' parameters in the sl@0: // metafunction's argument list, derivation from them is always a no-op; sl@0: // for instance: sl@0: // inherit::type == her sl@0: // inherit::type == struct unspecified : her, my {}; sl@0: // inherit::type == her sl@0: // inherit::type == her sl@0: // inherit::type == struct unspecified : her, my {}; sl@0: // inherit::type == empty_base sl@0: sl@0: #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) sl@0: sl@0: template< sl@0: typename BOOST_MPL_AUX_NA_PARAM(T1) sl@0: , typename BOOST_MPL_AUX_NA_PARAM(T2) sl@0: > sl@0: struct inherit2 sl@0: : T1, T2 sl@0: { sl@0: typedef inherit2 type; sl@0: BOOST_MPL_AUX_LAMBDA_SUPPORT(2, inherit2, (T1,T2)) sl@0: }; sl@0: sl@0: template< typename T1 > sl@0: struct inherit2 sl@0: { sl@0: typedef T1 type; sl@0: BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(2, inherit2, (T1,empty_base)) sl@0: }; sl@0: sl@0: template< typename T2 > sl@0: struct inherit2 sl@0: { sl@0: typedef T2 type; sl@0: BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(2, inherit2, (empty_base,T2)) sl@0: }; sl@0: sl@0: // needed to disambiguate the previous two in case when both sl@0: // T1 and T2 == empty_base sl@0: template<> sl@0: struct inherit2 sl@0: { sl@0: typedef empty_base type; sl@0: BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(2, inherit2, (empty_base,empty_base)) sl@0: }; sl@0: sl@0: #else sl@0: sl@0: namespace aux { sl@0: sl@0: template< bool C1, bool C2 > sl@0: struct inherit2_impl sl@0: { sl@0: template< typename Derived, typename T1, typename T2 > struct result_ sl@0: : T1, T2 sl@0: { sl@0: typedef Derived type_; sl@0: }; sl@0: }; sl@0: sl@0: template<> sl@0: struct inherit2_impl sl@0: { sl@0: template< typename Derived, typename T1, typename T2 > struct result_ sl@0: : T1 sl@0: { sl@0: typedef T1 type_; sl@0: }; sl@0: }; sl@0: sl@0: template<> sl@0: struct inherit2_impl sl@0: { sl@0: template< typename Derived, typename T1, typename T2 > struct result_ sl@0: : T2 sl@0: { sl@0: typedef T2 type_; sl@0: }; sl@0: }; sl@0: sl@0: template<> sl@0: struct inherit2_impl sl@0: { sl@0: template< typename Derived, typename T1, typename T2 > struct result_ sl@0: { sl@0: typedef T1 type_; sl@0: }; sl@0: }; sl@0: sl@0: } // namespace aux sl@0: sl@0: template< sl@0: typename BOOST_MPL_AUX_NA_PARAM(T1) sl@0: , typename BOOST_MPL_AUX_NA_PARAM(T2) sl@0: > sl@0: struct inherit2 sl@0: : aux::inherit2_impl< sl@0: is_empty_base::value sl@0: , is_empty_base::value sl@0: >::template result_< inherit2,T1,T2 > sl@0: { sl@0: typedef typename inherit2::type_ type; sl@0: BOOST_MPL_AUX_LAMBDA_SUPPORT(2, inherit2, (T1,T2)) sl@0: }; sl@0: sl@0: #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION sl@0: sl@0: BOOST_MPL_AUX_NA_SPEC(2, inherit2) sl@0: sl@0: #define BOOST_PP_ITERATION_PARAMS_1 \ sl@0: (3,(3, BOOST_MPL_LIMIT_METAFUNCTION_ARITY, )) sl@0: #include BOOST_PP_ITERATE() sl@0: sl@0: }} sl@0: sl@0: #endif // BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS sl@0: #endif // BOOST_MPL_INHERIT_HPP_INCLUDED sl@0: sl@0: ///// iteration sl@0: sl@0: #else sl@0: #define n_ BOOST_PP_FRAME_ITERATION(1) sl@0: sl@0: template< sl@0: BOOST_MPL_PP_DEFAULT_PARAMS(n_, typename T, na) sl@0: > sl@0: struct BOOST_PP_CAT(inherit,n_) sl@0: : inherit2< sl@0: typename BOOST_PP_CAT(inherit,BOOST_PP_DEC(n_))< sl@0: BOOST_MPL_PP_PARAMS(BOOST_PP_DEC(n_), T) sl@0: >::type sl@0: , BOOST_PP_CAT(T,n_) sl@0: > sl@0: { sl@0: BOOST_MPL_AUX_LAMBDA_SUPPORT( sl@0: n_ sl@0: , BOOST_PP_CAT(inherit,n_) sl@0: , (BOOST_MPL_PP_PARAMS(n_, T)) sl@0: ) sl@0: }; sl@0: sl@0: BOOST_MPL_AUX_NA_SPEC(n_, BOOST_PP_CAT(inherit,n_)) sl@0: sl@0: #if n_ == BOOST_MPL_LIMIT_METAFUNCTION_ARITY sl@0: /// primary template sl@0: template< sl@0: BOOST_MPL_PP_DEFAULT_PARAMS(n_, typename T, empty_base) sl@0: > sl@0: struct inherit sl@0: : BOOST_PP_CAT(inherit,n_) sl@0: { sl@0: }; sl@0: sl@0: // 'na' specialization sl@0: template<> sl@0: struct inherit< BOOST_MPL_PP_ENUM(5, na) > sl@0: { sl@0: template< sl@0: #if !defined(BOOST_MPL_CFG_NO_DEFAULT_PARAMETERS_IN_NESTED_TEMPLATES) sl@0: BOOST_MPL_PP_DEFAULT_PARAMS(n_, typename T, empty_base) sl@0: #else sl@0: BOOST_MPL_PP_PARAMS(n_, typename T) sl@0: #endif sl@0: > sl@0: struct apply sl@0: : inherit< BOOST_MPL_PP_PARAMS(n_, T) > sl@0: { sl@0: }; sl@0: }; sl@0: sl@0: BOOST_MPL_AUX_NA_SPEC_LAMBDA(n_, inherit) sl@0: BOOST_MPL_AUX_NA_SPEC_ARITY(n_, inherit) sl@0: BOOST_MPL_AUX_NA_SPEC_TEMPLATE_ARITY(n_, n_, inherit) sl@0: #endif sl@0: sl@0: #undef n_ sl@0: #endif // BOOST_PP_IS_ITERATING