Consider the following code:
template<typename>
struct S
{
operator S<int&>();
};
template<typename T>
void f(S<T&>);
int main()
{
f(S<int&&>{}); // gcc ok
// clang error
}
gcc uses the conversion operator on the temporary argument, returning S<int&>
which is matched by S<T&>
, and accepts the call.
clang doesn't consider the conversion operator, fails to match T&
against int&&
, and rejects the call.
So what does the language say should happen here?