I'm writing some test cases for C++ name-demangling code, and I get a weird error when I try to compile this: (the following is pathologically bad C++ code that I would never use in practice).
template<class U, class V>
class TStruct
{
U u;
V v;
public:
void setU(const U& newu) {u = newu; }
};
template<class T, class U>
class Oog
{
T t;
U u;
public:
Oog(const T& _t, const U& _u) : t(_t), u(_u) {}
void doit(TStruct<T,U> ts1, TStruct<U,T> ts2, U u1, T t1) {}
template<class F>
class Huh
{
F f;
public:
template<class V>
class Wham
{
V v;
public:
Wham(const V& _v) : v(_v) {}
void joy(TStruct<T,V> ts1, U u, F f) {}
};
};
int chakka(const Huh<T>::Wham<U>& wu, T t) {} // error here
};
error is as follows:
"typetest.cpp", line 165: error: nontype "Oog<T, U>::Huh<F>::Wham [with F=T]"
is not a template
Any ideas how I can fix?
The correct line should be as,
int chakka(const typename Huh<T>::template Wham<U>& wu, T t) ...
it's a type ^^^^^^^^ ^^^^^^^^ indicate that 'Wham' is a template
[Note: g++ is quite helpful in this case :) ]
You need to tell it that the Wham member of Huh will be a template:
const Huh<T>::template Wham<U> &
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With