![]() |
![]() ![]() ![]() ![]() |
![]() |
The MPL Reference Manual: bindBoost , ,
|
|||||||||||||||||||||
| Front Page / Metafunctions / Composition and Argument Binding / bind |
template<
typename F
>
struct bind0
{
// unspecified
// ...
};
template<
typename F, typename A1
>
struct bind1
{
// unspecified
// ...
};
...
template<
typename F, typename A1,... typename An
>
struct bindn
{
// unspecified
// ...
};
template<
typename F
, typename A1 = unspecified
...
, typename An = unspecified
>
struct bind
{
// unspecified
// ...
};
Связатьявляется первобытным для высшего порядка.Класс метафункцийСостав и связывание аргументов. По сути, это аналог компиляции времени аналогичной функциональности времени выполнения, предоставляемойBoost.BindиBoost. лямбдаБиблиотеки.
#include <boost/mpl/bind.hpp>
| Parameter | Requirement | Description |
|---|---|---|
| F | Класс метафункций | Класс метафункций для выполнения связывания. |
| А1...Ан | Любой тип | Аргументы, чтобы связать. |
Для любогометафункционального классаfи произвольных типовa1...a:
typedef bind<f,a1,...an> g; typedef bindn<f,a1,...an> g;
| Return type: | Класс метафункций |
|---|
| Semantics: | Equivalent to
struct g
{
template<
typename U1 = unspecified
...
, typename Un = unspecified
>
struct apply
: apply_wrapn<
typename h0<f,U1,...Un>::type
, typename h1<a1,U1,...Un>::type
...
, typename hn<an,U1,...Un>::type
>
{
};
};
гдеhkэквивалентно
template< typename X, typename U1,... typename Un > struct hk
: apply_wrapn<X,U1,...Un>
{
};
Еслиfилиakявляетсявыражением связиилизаполнителем, и
template< typename X, typename U1,... typename Un > struct hk
{
typedef X type;
};
otherwise. [Note: Every nth appearance of the unnamed placeholder in the bind<f,a1,...an> specialization is replaced with the corresponding numbered placeholder _n — end note] |
|---|
struct f1
{
template< typename T1 > struct apply
{
typedef T1 type;
};
};
struct f5
{
template< typename T1, typename T2, typename T3, typename T4, typename T5 >
struct apply
{
typedef T5 type;
};
};
typedef apply_wrap1<
bind1<f1,_1>
, int
>::type r11;
typedef apply_wrap5<
bind1<f1,_5>
, void,void,void,void,int
>::type r12;
BOOST_MPL_ASSERT(( is_same<r11,int> ));
BOOST_MPL_ASSERT(( is_same<r12,int> ));
typedef apply_wrap5<
bind5<f5,_1,_2,_3,_4,_5>
, void,void,void,void,int
>::type r51;
typedef apply_wrap5<
bind5<f5,_5,_4,_3,_2,_1>
, int,void,void,void,void
>::type r52;
BOOST_MPL_ASSERT(( is_same<r51,int> ));
BOOST_MPL_ASSERT(( is_same<r52,int> ));
Статья The MPL Reference Manual: bind раздела может быть полезна для разработчиков на c++ и boost.
:: Главная :: ::
реклама |