<分区>
我遇到了以下错误:
class NormalClass
{
public:
constexpr NormalClass() : arr{}, debug_ptr((int*)arr)
{
//'reinterpret_cast' is not a constant expression
//cast that performs the conversions of a reinterpret_cast is not allowed in a constant expression
}
public:
char arr[5];
int* debug_ptr;
};
constinit NormalClass normal;
int main()
{
}
最初这是在一个模板中,带有 (T*) 转换。为什么在 constexpr 中不允许这样的转换?