The following code compiles with MSVC and gcc, but not with clang. Why is that so?
It seems like if ADL would not work if CallFoo ()
is constexpr
. See the comment.
template <class T>
constexpr void CallFoo () // Remove constexpr to fix clang compilation error.
{
Foo (T ());
}
class Apple {};
int main ()
{
CallFoo<Apple> ();
}
constexpr void Foo (Apple)
{
}
Clang error message (see on godbolt.org):
<source>:4:5: error: use of undeclared identifier 'Foo'
Foo (T ());
^
<source>:13:5: note: in instantiation of function template specialization 'CallFoo<Apple>' requested here
CallFoo<Apple> ();
^
constexpr
in the commented line, all thee compile it successfully. – Intuitional