Closed
Description
Consider this example:
#include <iostream>
struct A
{
void foo() {std::cout << "1\n";}
template <typename T = int>
void foo() {std::cout << "2\n";}
};
int main()
{
A x;
x.template foo();
}
Clang prints 2
. But the code shouldn't be accepted at all, since [temp.names]/5
says that the name after .template
/->template
must be a template-id, aka must have explicitly specified template arguments. Here's a stackoverflow thread.
Note: this doesn't apply to foo::template MyClassTemplate
, which is legal, but seems to be made optional (and deprecated at the same time) in C++2b.