以下代码在Clang中编译,但在GCC中不编译.当我operator()使用左值调用时,它可以工作,但不能使用右值.为什么?
struct S
{
bool operator()() const & { return true; }
bool operator()() const && { return true; }
};
int main()
{
S s;
s(); // works
S()(); // fails (error: call of '(S) ()' is ambiguous)
}
Run Code Online (Sandbox Code Playgroud)
我正在GCC 4.8上编译这段代码.