Front Page / Metafunctions / Miscellaneous / identity

# identity

### Synopsis

    template<
          typename X
        >
    struct identity
    {
        typedef X type;
    };

### Description

The identity metafunction. Returns `X` unchanged.

### Header

    #include <boost/mpl/identity.hpp>

### Model of

Metafunction

### Parameters

Parameter | Requirement | Description
--- | --- | ---
`X` | Any type | An argument to be returned.

### Expression semantics

For an arbitrary type `x`:

    typedef identity<x>::type r;

Return type: | A type.

Semantics:

Equivalent to

    typedef x r;

Postcondition: | `is_same<r,x>::value == true`.

### Example

    typedef apply< identity<_1>, char >::type t1;
    typedef apply< identity<_2>, char,int >::type t2;

    BOOST_MPL_ASSERT(( is_same< t1, char > ));
    BOOST_MPL_ASSERT(( is_same< t2, int > ));

### See also

Metafunctions, Placeholders, Trivial Metafunctions, `always`, `apply`