断言失败:__is_complete_or_unbounded 数组,大小为 0

问题描述 投票:0回答:1

编译 HHVM 时,代码失败,原因是:

/usr/include/c++/10/type_traits:918:52: error: non-constant condition for static assertion
  918 |       static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),

__is_complete_or_unbounded
实际上做什么/检查什么?

在构造最后一个成员变量如下的对象时出现问题:

  value_type cell[0]

构造函数没有初始化这个成员,这是问题所在吗?我将如何初始化 value_type 变量?

c++ g++ type-traits
1个回答
0
投票

在 C++ 中,数组的大小不能为零。

来自数组声明符文档

如果表达式是常量表达式,则其值应大于零。

© www.soinside.com 2019 - 2024. All rights reserved.