【发布时间】:2018-09-22 10:19:55
【问题描述】:
我有一段代码适用于 g++/clang++。最近有人向我报告它与 Visual C++ 冲突。
代码是这样的:
namespace q {
template <typename X, typename Y>
struct A {};
}
template <typename X>
struct B {
template <typename Y>
friend struct q::A;
};
int main() {
return 0;
}
VC++ 返回以下错误:
source_file.cpp(9): error C2976: 'q::A': too few template arguments
source_file.cpp(3): note: see declaration of 'q::A'
source_file.cpp(10): note: see reference to class template instantiation 'B<X>' being compiled
谁是正确的?有便携的方法吗?
【问题讨论】:
标签: c++ c++11 visual-c++ g++ clang++