以下代码片段在g++和clang++下运行良好:
// bsp1.cc class A { public: A(int, char const *); int value; const char * name; class B { public: static const A many_as[]; A const B::many_as[] { { 0, "zero" }, { 1, "one" }, { 2, "two" }, { 3, "three" }, { 77, 0 } };
当我将B类更改为模板时:
// bsp2.cc class A { public: A(int, char const *); int value; const char * name; template<typename T> class B { public: static const A many_as[]; template<> A const B< int >::many_as[] { { 0, "zero" }, { 1, "one" }, { 2, "two" }, { 3, "three" },