1 .. Metafunctions/Miscellaneous//inherit |30
12 typename T1, typename T2
16 typedef |unspecified| type;
22 typename T1, typename T2,\ |...| typename T\ *n*
26 typedef |unspecified| type;
33 , typename T\ *n* = |unspecified|
37 typedef |unspecified| type;
44 Returns an unspecified class type publically derived from |T1...Tn|.
45 Guarantees that derivation from |empty_base| is always a no-op,
46 regardless of the position and number of |empty_base| classes in
55 #include <boost/mpl/inherit.hpp>
67 +---------------+-------------------+-----------------------------------+
68 | Parameter | Requirement | Description |
69 +===============+===================+===================================+
70 | |T1...Tn| | A class type | Classes to derived from. |
71 +---------------+-------------------+-----------------------------------+
77 For artibrary class types |t1...tn|:
81 typedef inherit2<t1,t2>::type r;
87 ``t1`` and ``t2`` are complete types.
90 If both ``t1`` and ``t2`` are identical to ``empty_base``, equivalent to
97 otherwise, if ``t1`` is identical to ``empty_base``, equivalent to
104 otherwise, if ``t2`` is identical to ``empty_base``, equivalent to
111 otherwise equivalent to
115 struct r : t1, t2 {};
117 .. ...........................................................................
121 typedef inherit\ *n*\<t1,t2,\ |...|\ t\ *n*\ >::type r;
127 |t1...tn| are complete types.
136 inherit\ *n-1*\<t1,t2,\ |...|\ t\ *n-1*\>::type
143 .. ...........................................................................
148 typedef inherit<t1,t2,\ |...|\ t\ *n*\ >::type r;
151 |t1...tn| are complete types.
161 typedef inherit\ *n*\<t1,t2,\ |...|\ t\ *n*\ >::type r;
168 Amortized constant time.
176 struct udt1 { int n; };
179 typedef inherit<udt1,udt2>::type r1;
180 typedef inherit<empty_base,udt1>::type r2;
181 typedef inherit<empty_base,udt1,empty_base,empty_base>::type r3;
182 typedef inherit<udt1,empty_base,udt2>::type r4;
183 typedef inherit<empty_base,empty_base>::type r5;
185 BOOST_MPL_ASSERT(( is_base_and_derived< udt1, r1> ));
186 BOOST_MPL_ASSERT(( is_base_and_derived< udt2, r1> ));
187 BOOST_MPL_ASSERT(( is_same< r2, udt1> ));
188 BOOST_MPL_ASSERT(( is_same< r3, udt1 > ));
189 BOOST_MPL_ASSERT(( is_base_and_derived< udt1, r4 > ));
190 BOOST_MPL_ASSERT(( is_base_and_derived< udt2, r4 > ));
191 BOOST_MPL_ASSERT(( is_same< r5, empty_base > ));
197 |Metafunctions|, |empty_base|, |inherit_linearly|, |identity|
200 .. copyright:: Copyright © 2001-2009 Aleksey Gurtovoy and David Abrahams
201 Distributed under the Boost Software License, Version 1.0. (See accompanying
202 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)