![]() |
![]() ![]() ![]() ![]() |
![]() |
The MPL Reference Manual: inheritBoost , ,
|
||||||||||||||||||||||||||||||||
| Front Page / Metafunctions / Miscellaneous / inherit |
template<
typename T1, typename T2
>
struct inherit2
{
typedef unspecified type;
};
...
template<
typename T1, typename T2,... typename Tn
>
struct inheritn
{
typedef unspecified type;
};
template<
typename T1
, typename T2
...
, typename Tn = unspecified
>
struct inherit
{
typedef unspecified type;
};
Возвращает неопределенный тип класса, публично полученный изT1,T2, ...Тн. Гарантии, что вывод изempty_baseвсегда является no-op, независимо от положения и количестваempty_baseклассов вT1,Т2,Тн.
#include <boost/mpl/inherit.hpp>
| Parameter | Requirement | Description |
|---|---|---|
| T1,T2, ...Tn | Тип класса | Классы, полученные из. |
Для типов верхнего классаt1,t2, ...tn:
typedef inherit2<t1,t2>::type r;
| Return type: | A class type. |
|---|---|
| Precondition: | t1 and t2 are complete types. |
| Semantics: | If both t1 and t2 are identical to empty_base, equivalent to typedef empty_base r; В противном случае, еслиt1идентиченпустому_основанию, эквивалентно typedef t2 r; Еслиt2идентиченпустому_основанию, то typedef t1 r; иным эквивалентом
struct r : t1, t2 {};
|
typedef inheritn<t1,t2,...tn>::type r;
| Return type: | A class type. |
|---|---|
| Precondition: | t1,t2,... tn are complete types. |
| Semantics: | Equivalent to
struct r
: inherit2<
inheritn-1<t1,t2,...tn-1>::type
, tn
>
{
};
|
typedef inherit<t1,t2,...tn>::type r;
| Precondition: | t1,t2,... tn are complete types. |
|---|---|
| Return type: | A class type. |
| Semantics: | Equivalent to typedef inheritn<t1,t2,...tn>::type r; |
Амортизированное постоянное время.
struct udt1 { int n; };
struct udt2 {};
typedef inherit<udt1,udt2>::type r1;
typedef inherit<empty_base,udt1>::type r2;
typedef inherit<empty_base,udt1,empty_base,empty_base>::type r3;
typedef inherit<udt1,empty_base,udt2>::type r4;
typedef inherit<empty_base,empty_base>::type r5;
BOOST_MPL_ASSERT(( is_base_and_derived< udt1, r1> ));
BOOST_MPL_ASSERT(( is_base_and_derived< udt2, r1> ));
BOOST_MPL_ASSERT(( is_same< r2, udt1> ));
BOOST_MPL_ASSERT(( is_same< r3, udt1 > ));
BOOST_MPL_ASSERT(( is_base_and_derived< udt1, r4 > ));
BOOST_MPL_ASSERT(( is_base_and_derived< udt2, r4 > ));
BOOST_MPL_ASSERT(( is_same< r5, empty_base > ));
Статья The MPL Reference Manual: inherit раздела может быть полезна для разработчиков на c++ и boost.
:: Главная :: ::
реклама |