I have problem with the syntax needed to initialize a static member in a class template. Here is the code (I tried to reduce it as much as I could):
template <typename T>
struct A
{
template <typename T1>
struct B
{
static T1 b;
};
B<T> b;
typedef B<T> BT;
T val() { return b.b; }
};
template <typename T>
T A<T>::BT::b;
struct D
{
D() : d(0) {}
int d;
};
int main()
{
A<D> a;
return a.val().d;
}
With g++
, the error I get is:
error: too few template-parameter-lists
Any ideas how to initialize b?
Note that I would like to keep the typedef, as in my real code, B is way more complex than that.