The following code compiles in Clang but not in GCC. When I call operator()
with an lvalue it works, but not with an rvalue. Why?
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)
}
I'm compiling this code on GCC 4.8.