我有以下嵌套模板
class A {
template <typename T> class B {
template <typename U> void foo(U arg);
};
};
我正在尝试像这样定义嵌套模板:
template <typename T, typename U> void
A::B<T>::foo(U arg) {...}
但是我收到declaration is incompatible with function template
错误。这样做的合法语法是什么?
最佳答案
您需要分隔模板声明:
template <typename T>
template <typename U>
void
A::B<T>::foo(U arg) { … }
关于c++ - 定义嵌套模板的合法语法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16470163/