我正在为C++名称解码代码编写一些测试用例,当我尝试编译它时,我得到一个奇怪的错误:(以下是病态上不好的C++代码,我在实践中永远不会使用).
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
};
Run Code Online (Sandbox Code Playgroud)
错误如下:
"typetest.cpp", line 165: error: nontype "Oog<T, U>::Huh<F>::Wham [with F=T]"
is not a template
Run Code Online (Sandbox Code Playgroud)
我有什么想法可以解决?
正确的行应该是,
int chakka(const typename Huh<T>::template Wham<U>& wu, T t) ...
it's a type ^^^^^^^^ ^^^^^^^^ indicate that 'Wham' is a template
Run Code Online (Sandbox Code Playgroud)
[注意:在这种情况下,g ++非常有用 :)]
| 归档时间: |
|
| 查看次数: |
122 次 |
| 最近记录: |