【发布时间】:2016-07-03 19:47:45
【问题描述】:
namespace MyNS {
template <>
class Test<Test1> {
public:
constexpr static char const *description[] = { "X`", "Y1"};
/*
...
...
*/
}
constexpr char const * Test<Test1>::description[];
/* Above definition is required when compiling with GCC but MSVC compiler gives error saying 'description' is redeclared. */
/* **Omitting definition of 'description', which is written outside class in namespace, causes successful compilation by MSVC but failure in GCC** */
}
是否有一种在 constexpr 之上定义、声明和初始化的通用方法,以便 MSVC 和 GCC 都能成功编译代码?
【问题讨论】:
-
g++ 版本? MSVC 版本?编译器选项? minimal reproducible example?
标签: c++