i have some code like this:
// Factory.h
template <typename TFactoryTable, typename TBaseProduct>
class FactoryTable {
public:
static TFactoryTable instance;
};
template <typename TFactoryTable, typename TBaseProduct>
TFactoryTable FactoryTable<TFactoryTable, TBaseProduct>::instance;
// Foo.h
class BaseFoo {};
class FooFactoryTable : public FactoryTable<FooFactoryTable, BaseFoo> {};
// Bar.h
class BaseBar {};
class BarFactoryTable : public FactoryTable<BarFactoryTable, BaseBar> {};
// main.cpp
void test() {
auto& t = FooFactoryTable::instance;
}
i put the define of static member "instance" in FactoryTable<>, so that, i can force factory tables (FooFactoryTable, BarFactoryTable,...) to use the same way to define it's singleton. these code compiled well by visual studio 2012(v110), but the editor (IntelliSense not compiler) report an error on FooFactoryTable::instance in test():
Error: class "FooFactoryTable" has no member "instance"
if i change the declaration & definition of instance to be of type "FactoryTable" (not TFactoryTable), then the editor won't report the error. so i worry that, is this (compile well) a msvc only feature, or a standard c++ feature? because the code's target platform is android and iphone, and need to be compiled by gcc.