Boost C++ 库

...世界上最受推崇、设计最精良的 C++ 库项目之一。 Herb SutterAndrei Alexandrescu, C++ Coding Standards

MPL 参考手册:char_ - Boost C++ 函数库
首页 / 数据类型 / 数值 / char_

char_

提要

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

描述

适用于char.

参数

Parameter 要求 描述
N 一个字符常量 要包装的值。

表达式语义

表达式的语义仅在其与 Integral Constant 不同或未在其中定义的地方定义。

用于任意字符常量c:

表达式 语义
char_<c> 一个 Integral Constantx使得x::value == candx::value_type与...相同char.

示例

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' );