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 / Data Types / Numeric / char_

char_

Synopsis

template<
      char N
    >
struct char_
{
    // unspecified
    // ...
};

Description

An Integral Constant wrapper for char.

Header

#include <boost/mpl/char.hpp>

Model of

Integral Constant

Parameters

Parameter Requirement Description
N A character constant A value to wrap.

Expression semantics

The semantics of an expression are defined only where they differ from, or are not defined in Integral Constant.

For arbitrary character constant c:

Expression Semantics
char_<c> An Integral Constant x such that x::value == c and x::value_type is identical to char.

Example

typedef char_<'c'> c;

BOOST_MPL_ASSERT(( is_same< c::value_type, char > ));
BOOST_MPL_ASSERT(( is_same< c::type, c > ));
BOOST_MPL_ASSERT(( is_same< next< c >::type, char_<'d'> > ));
BOOST_MPL_ASSERT(( is_same< prior< c >::type, char_<'b'> > ));
BOOST_MPL_ASSERT_RELATION( (c::value), ==, 'c' );
assert( c() == 'c' );

See also

Data Types, Integral Constant, int_, size_t, integral_c