C++ VS2013中静态constexpr阵列出现错误C2864(CTP_Nov2013)
以下是标题中的代码:C++ VS2013中静态constexpr阵列出现错误C2864(CTP_Nov2013),c++,arrays,c++11,visual-studio-2013,constexpr,C++,Arrays,C++11,Visual Studio 2013,Constexpr,以下是标题中的代码: struct FormContainer{ enum Forms{ Stuff, FormCount}; enum MoreForms{ MoreStuff = FormCount, MoreFormCount}; static std::array<UInt32, MoreFormCount> Forms; static constexpr UInt32 FormArrayCount = 2; static const
struct FormContainer{
enum Forms{ Stuff, FormCount};
enum MoreForms{ MoreStuff = FormCount, MoreFormCount};
static std::array<UInt32, MoreFormCount> Forms;
static constexpr UInt32 FormArrayCount = 2;
static constexpr char* FormArrayNames[FormArrayCount] { "AnArray", "2ndArray" };
static constexpr UInt32 FormArrayEndingIndex[FormArrayCount] { FormCount, MoreFormCount };
};
struct FormContainer{
枚举表单{Stuff,FormCount};
枚举MoreForms{MoreStuff=FormCount,MoreFormCount};
静态std::数组形式;
静态constexpr UInt32 formaraycount=2;
静态constexpr char*FormArrayNames[FormArrayCount]{“AnArray”,“2ndArray”};
静态constexpr UInt32 FormArrayEndingIndex[FormArrayCount]{FormCount,MoreFormCount};
};
为什么会出现以下错误:
错误C2864:“Common::FormContainer::FormArrayEndingIndex”:具有类内初始值设定项的静态数据成员必须具有非易失性常量整数类型
对于最后两行(数组初始化)?ctp没有完整的constexpr支持,这可能就是原因。你应该在Microsoft Connect上填写错误报告。找到它。。。CTP支持C++11 constexpr,成员函数除外。(另一个限制是不支持数组。)此外,它不支持C++14的扩展constexpr规则