我有以下代码:
#include <array>
#include <iostream>
class ExternalGeometryExtension
{
public:
enum Flag {
Defining = 0,
Frozen = 1,
Detached = 2,
Missing = 3,
Sync = 4,
NumFlags
};
constexpr static std::array<const char *,NumFlags> flag2str{{ "Defining", "Frozen", "Detached","Missing", "Sync" }};
};
int main()
{
std::cout << ExternalGeometryExtension::flag2str[ExternalGeometryExtension::Frozen] << std::endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
可以使用以下版本编译良好:clang版本5.0.0和gcc(Ubuntu 4.8.4-2ubuntu1〜14.04.3)4.8.4
无法使用MSVC2013进行编译。
编译错误是:
#include <array>
#include <iostream>
class ExternalGeometryExtension
{
public:
enum Flag {
Defining = 0,
Frozen = 1,
Detached = 2,
Missing = 3,
Sync …Run Code Online (Sandbox Code Playgroud)