Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
Front Page / Metafunctions / Miscellaneous / always

always

Synopsis

template< 
      typename X
    >
struct always
{
    // unspecified
    // ...
};

Description

always<X> specialization is a variadic Metafunction Class always returning the same type, X, regardless of the number and types of passed arguments.

Header

#include <boost/mpl/always.hpp>

Model of

Metafunction Class

Parameters

Parameter Requirement Description
X Any type A type to be returned.

Expression semantics

For an arbitrary type x:

typedef always<x> f;
Return type:Metafunction Class.
Semantics:

Equivalent to

struct f : bind< identity<_1>, x > {};

Example

typedef always<true_> always_true;

BOOST_MPL_ASSERT(( apply< always_true,false_> ));
BOOST_MPL_ASSERT(( apply< always_true,false_,false_ > ));
BOOST_MPL_ASSERT(( apply< always_true,false_,false_,false_ > ));

See also

Metafunctions, Metafunction Class, identity, bind, apply