The following code compiles in Clang but does not in GCC:
template<typename T>
struct Widget
{
template<typename U>
void foo(U)
{
}
template<>
void foo(int*)
{
}
};
According to the C++ standard ([temp.expl.spec], paragraph 2):
An explicit specialization may be declared in any scope in which the corresponding primary template may be
defined
Is this a bug in GCC and if so how can I find it in its bug tracker?
This is GCC's output:
prog.cc:13:14: error: explicit specialization in non-namespace scope 'struct Widget<T>'
template<>
^
I'm using GCC HEAD 8.0.1, with -std=c++2a
.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…