我在使用Visual Studio 2010初始化std :: array时遇到问题。我知道使用现代编译器,我可以执行以下操作
#include <array>
class A
{
A() : arr({1,2,3,4,5,6}) {}
public:
std::array<float, 6> arr;
};
但是,Visual Studio 2010不允许这样做(因为它不完全支持C++11
)。但是,还有其他我想念的方式吗?
答案 0 :(得分:4)
A。 聚合初始化是C ++ 11的概念,Visual Studio 2010实现了C ++ 03标准。
另一种方法是在类构造函数中手动构建数组。
如果您需要能够创建const
的{{1}}实例,请使用A
函数构建该数组,然后将内容复制到static
中。 / p>