为什么下面的代码可以用 GCC 编译,但不能用 Clang?谁是对的,为什么?
class TF
{
private:
struct S
{
};
template <typename T> friend void F(T x, S s, int v = 5);
};
template <typename T>
void F(T x, TF::S s, int v)
{
}
使用 clang++ 时出现以下错误:
error: friend declaration specifying a default argument must be a definition
template <typename T> friend void F(T x, S s, int v = 5);
^
error: friend declaration specifying a default argument must be the only declaration
void F(T x, TF::S s, int v)
^
note: previous declaration is here
template <typename T> friend void F(T x, S s, int v = 5);
GCC 版本:g++ (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
Clang 版本:clang 版本 6.0.0-1ubuntu2
我该如何解决这个问题?