This may seem a bit esoteric, but I have a class structure like this, where a singleton template class is defined in a different namespace than the class actually using it.
namespace F{
template<typename>
struct Foo{
static Foo instance;
};
}
namespace B{
struct Bar{};
F::Foo<Bar> F::Foo<Bar>::instance; //error C2888
}
Which yields:
error C2888: 'Foo<void> Foo<void>::instance' : symbol cannot be defined within namespace 'B'
I know that this is how it's supposed to be, but in my instance Foo
is part of my library and Bar
is defined by the client, so they won't necessarily be part of the same namespace. The part where Foo<void>::instance
is defined is part of a macro, so I can hide complexity from the user.
Is there any way that enables me to define the member of a class from inside another namespace?