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

Front Page / Data Types / Numeric / int_

int_

Synopsis

template<
      int N
    >
struct int_
{
    // unspecified
    // ...
};

Description

An Integral Constant wrapper for int.

Header

#include <boost/mpl/int.hpp>

Model of

Integral Constant

Parameters

Parameter Requirement Description
N An integral 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 integral constant n:

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

Example

typedef int_<8> eight;

BOOST_MPL_ASSERT(( is_same< eight::value_type, int > ));
BOOST_MPL_ASSERT(( is_same< eight::type, eight > ));
BOOST_MPL_ASSERT(( is_same< next< eight >::type, int_<9> > ));
BOOST_MPL_ASSERT(( is_same< prior< eight >::type, int_<7> > ));
BOOST_MPL_ASSERT_RELATION( (eight::value), ==, 8 );
assert( eight() == 8 );

See also

Data Types, Integral Constant, long_, size_t, integral_c