2 #if !defined(BOOST_PP_IS_ITERATING)
\r
6 #ifndef BOOST_MPL_INHERIT_HPP_INCLUDED
\r
7 #define BOOST_MPL_INHERIT_HPP_INCLUDED
\r
9 // Copyright Aleksey Gurtovoy 2001-2004
\r
11 // Distributed under the Boost Software License, Version 1.0.
\r
12 // (See accompanying file LICENSE_1_0.txt or copy at
\r
13 // http://www.boost.org/LICENSE_1_0.txt)
\r
15 // See http://www.boost.org/libs/mpl for documentation.
\r
17 // $Id: inherit.hpp 49267 2008-10-11 06:19:02Z agurtovoy $
\r
18 // $Date: 2008-10-11 02:19:02 -0400 (Sat, 11 Oct 2008) $
\r
19 // $Revision: 49267 $
\r
21 #if !defined(BOOST_MPL_PREPROCESSING_MODE)
\r
22 # include <boost/mpl/empty_base.hpp>
\r
23 # include <boost/mpl/aux_/na_spec.hpp>
\r
24 # include <boost/mpl/aux_/lambda_support.hpp>
\r
27 #include <boost/mpl/aux_/config/use_preprocessed.hpp>
\r
29 #if !defined(BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS) \
\r
30 && !defined(BOOST_MPL_PREPROCESSING_MODE)
\r
32 # define BOOST_MPL_PREPROCESSED_HEADER inherit.hpp
\r
33 # include <boost/mpl/aux_/include_preprocessed.hpp>
\r
37 # include <boost/mpl/limits/arity.hpp>
\r
38 # include <boost/mpl/aux_/preprocessor/params.hpp>
\r
39 # include <boost/mpl/aux_/preprocessor/default_params.hpp>
\r
40 # include <boost/mpl/aux_/preprocessor/enum.hpp>
\r
41 # include <boost/mpl/aux_/config/ctps.hpp>
\r
42 # include <boost/mpl/aux_/config/dtp.hpp>
\r
44 # include <boost/preprocessor/iterate.hpp>
\r
45 # include <boost/preprocessor/dec.hpp>
\r
46 # include <boost/preprocessor/cat.hpp>
\r
48 namespace boost { namespace mpl {
\r
50 // 'inherit<T1,T2,..,Tn>' metafunction; returns an unspecified class type
\r
51 // produced by public derivation from all metafunction's parameters
\r
52 // (T1,T2,..,Tn), except the parameters of 'empty_base' class type;
\r
53 // regardless the position and number of 'empty_base' parameters in the
\r
54 // metafunction's argument list, derivation from them is always a no-op;
\r
56 // inherit<her>::type == her
\r
57 // inherit<her,my>::type == struct unspecified : her, my {};
\r
58 // inherit<empty_base,her>::type == her
\r
59 // inherit<empty_base,her,empty_base,empty_base>::type == her
\r
60 // inherit<her,empty_base,my>::type == struct unspecified : her, my {};
\r
61 // inherit<empty_base,empty_base>::type == empty_base
\r
63 #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
\r
66 typename BOOST_MPL_AUX_NA_PARAM(T1)
\r
67 , typename BOOST_MPL_AUX_NA_PARAM(T2)
\r
72 typedef inherit2 type;
\r
73 BOOST_MPL_AUX_LAMBDA_SUPPORT(2, inherit2, (T1,T2))
\r
76 template< typename T1 >
\r
77 struct inherit2<T1,empty_base>
\r
80 BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(2, inherit2, (T1,empty_base))
\r
83 template< typename T2 >
\r
84 struct inherit2<empty_base,T2>
\r
87 BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(2, inherit2, (empty_base,T2))
\r
90 // needed to disambiguate the previous two in case when both
\r
91 // T1 and T2 == empty_base
\r
93 struct inherit2<empty_base,empty_base>
\r
95 typedef empty_base type;
\r
96 BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(2, inherit2, (empty_base,empty_base))
\r
103 template< bool C1, bool C2 >
\r
104 struct inherit2_impl
\r
106 template< typename Derived, typename T1, typename T2 > struct result_
\r
109 typedef Derived type_;
\r
114 struct inherit2_impl<false,true>
\r
116 template< typename Derived, typename T1, typename T2 > struct result_
\r
124 struct inherit2_impl<true,false>
\r
126 template< typename Derived, typename T1, typename T2 > struct result_
\r
134 struct inherit2_impl<true,true>
\r
136 template< typename Derived, typename T1, typename T2 > struct result_
\r
145 typename BOOST_MPL_AUX_NA_PARAM(T1)
\r
146 , typename BOOST_MPL_AUX_NA_PARAM(T2)
\r
149 : aux::inherit2_impl<
\r
150 is_empty_base<T1>::value
\r
151 , is_empty_base<T2>::value
\r
152 >::template result_< inherit2<T1,T2>,T1,T2 >
\r
154 typedef typename inherit2::type_ type;
\r
155 BOOST_MPL_AUX_LAMBDA_SUPPORT(2, inherit2, (T1,T2))
\r
158 #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
\r
160 BOOST_MPL_AUX_NA_SPEC(2, inherit2)
\r
162 #define BOOST_PP_ITERATION_PARAMS_1 \
\r
163 (3,(3, BOOST_MPL_LIMIT_METAFUNCTION_ARITY, <boost/mpl/inherit.hpp>))
\r
164 #include BOOST_PP_ITERATE()
\r
168 #endif // BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
\r
169 #endif // BOOST_MPL_INHERIT_HPP_INCLUDED
\r
174 #define n_ BOOST_PP_FRAME_ITERATION(1)
\r
177 BOOST_MPL_PP_DEFAULT_PARAMS(n_, typename T, na)
\r
179 struct BOOST_PP_CAT(inherit,n_)
\r
181 typename BOOST_PP_CAT(inherit,BOOST_PP_DEC(n_))<
\r
182 BOOST_MPL_PP_PARAMS(BOOST_PP_DEC(n_), T)
\r
184 , BOOST_PP_CAT(T,n_)
\r
187 BOOST_MPL_AUX_LAMBDA_SUPPORT(
\r
189 , BOOST_PP_CAT(inherit,n_)
\r
190 , (BOOST_MPL_PP_PARAMS(n_, T))
\r
194 BOOST_MPL_AUX_NA_SPEC(n_, BOOST_PP_CAT(inherit,n_))
\r
196 #if n_ == BOOST_MPL_LIMIT_METAFUNCTION_ARITY
\r
197 /// primary template
\r
199 BOOST_MPL_PP_DEFAULT_PARAMS(n_, typename T, empty_base)
\r
202 : BOOST_PP_CAT(inherit,n_)<BOOST_MPL_PP_PARAMS(n_, T)>
\r
206 // 'na' specialization
\r
208 struct inherit< BOOST_MPL_PP_ENUM(5, na) >
\r
211 #if !defined(BOOST_MPL_CFG_NO_DEFAULT_PARAMETERS_IN_NESTED_TEMPLATES)
\r
212 BOOST_MPL_PP_DEFAULT_PARAMS(n_, typename T, empty_base)
\r
214 BOOST_MPL_PP_PARAMS(n_, typename T)
\r
218 : inherit< BOOST_MPL_PP_PARAMS(n_, T) >
\r
223 BOOST_MPL_AUX_NA_SPEC_LAMBDA(n_, inherit)
\r
224 BOOST_MPL_AUX_NA_SPEC_ARITY(n_, inherit)
\r
225 BOOST_MPL_AUX_NA_SPEC_TEMPLATE_ARITY(n_, n_, inherit)
\r
229 #endif // BOOST_PP_IS_ITERATING
\r