我正在尝试实现一种具有多重继承的 CRTP(如果我很了解它是什么)。
我的主要目标是有一个统一的方式来访问每个子类的实例列表。
可能问题似乎存在于命名空间的使用上。
这是最简单版本的代码:http: //ideone.com/rFab5
我真正的问题更类似于:http: //ideone.com/U7cAf
我有一个使用 clang++ 的额外警告:
test.cpp:28:63: warning: static data member specialization of 'instances' must originally be declared in namespace 'NS1'; accepted as a C++0x extension [-Wc++0x-extensions]
template <> std::list<NS1::Derived*> NS1::Base<NS1::Derived>::instances;
^
test.cpp:15:34: note: explicitly specialized declaration is here
static std::list<T*> instances;
问题已更新,因为它使用命名空间的行为不同。
重新编辑问题以在 Ideone 上发布代码