Char是算术类型?

2 c++ arithmetic-expressions matrix char

我创建了一个Matrix类,使用

static_assert(std::is_arithmetic<T>::value,"");
Run Code Online (Sandbox Code Playgroud)

检查模板类型是否为算术类型.所以我尝试了

Matrix<char> matrix1(3,3); // ctor takes number of rows and columns
Run Code Online (Sandbox Code Playgroud)

它的工作原理.不使用char类型调用static_assert函数.这是正常的?char看起来像算术类型?

das*_*ght 5

来自参考:

如果T是算术类型(即整数类型或浮点类型),则提供成员常量值等于true.对于任何其他类型,值为false.

char是一个整体类型,所以答案是true.适合a的小整数char通常被解释为特定字符编码空间中的代码点这一事实是次要的.