The MPL Reference Manual: apply_wrap

Front Page / Metafunctions / Invocation / apply_wrap

# apply_wrap

### Synopsis

    template<
          typename F
        >
    struct apply_wrap0
    {
        typedef unspecified type;
    };

    template<
          typename F, typename A1
        >
    struct apply_wrap1
    {
        typedef unspecified type;
    };

    ...

    template<
          typename F, typename A1,... typename An
        >
    struct apply_wrapn
    {
        typedef unspecified type;
    };

### Description

Invokes a Metafunction Class `F` with arguments `A1`,... `An`.

In essence, `apply_wrap` forms are nothing more than syntactic wrappers around `F::apply<A1,... An>::type` / `F::apply::type` expressions (hence the name). They provide a more concise notation and higher portability than their underlaying constructs at the cost of an extra template instantiation.

### Header

    #include <boost/mpl/apply_wrap.hpp>

### Parameters

Parameter | Requirement | Description
--- | --- | ---
`F` | Metafunction Class | A metafunction class to invoke.
`A1`,... `An` | Any type | Invocation arguments.

### Expression semantics

For any Metafunction Class `f` and arbitrary types `a1`,... `an`:

    typedef apply_wrapn<f,a1,...an>::type t;

Return type: | Any type.
Semantics: | If `n > 0`, equivalent to `typedef f::apply<a1,... an>::type t;`, otherwise equivalent to either `typedef f::apply::type t;` or `typedef f::apply<>::type t;` depending on whether `f::apply` is a class or a class template.

### Example

    struct f0
    {
        template< typename T = int > struct apply
        {
            typedef char type;
        };
    };

    struct g0
    {
        struct apply { typedef char type; };
    };

    struct f2
    {
        template< typename T1, typename T2 > struct apply
        {
            typedef T2 type;
        };
    };

    typedef apply_wrap0< f0 >::type r1;
    typedef apply_wrap0< g0 >::type r2;
    typedef apply_wrap2< f2,int,char >::type r3;

    BOOST_MPL_ASSERT(( is_same<r1,char> ));
    BOOST_MPL_ASSERT(( is_same<r2,char> ));
    BOOST_MPL_ASSERT(( is_same<r3,char> ));

### See also

Metafunctions, invocation, apply, lambda, quote, bind, protect