哪一个编译器是对的?
class A
{
public:
template <typename T>
void fun(void (*f)() = funPrivate<T>) {}
private:
template <typename T>
static void funPrivate() {}
};
int main(int argc, char** argv)
{
A a;
a.fun<int>();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
编译正常:gcc版本4.8.5(Ubuntu 4.8.5-2ubuntu1~14.04.1)
导致错误:clang版本3.4-1ubuntu3(标签/ RELEASE_34/final)(基于LLVM 3.4)
a.cpp:5:27: error: 'funPrivate' is a private member of 'A'
void fun(void (*f)() = funPrivate<T>) {}
^~~~~~~~~~~~~
a.cpp:14:3: note: in instantiation of default function argument expression for 'fun<int>' required here
a.fun<int>();
^
a.cpp:8:16: note: declared private here
static void …Run Code Online (Sandbox Code Playgroud)