There is this code:
class A;
template
void fun() {
A a;
}
class A {
public:
A() { }
};
int main() {
fun();
return
clang++
is using the correct behavior, this is described in section 4.6/9
of the standard (n1905).
Templates 14.6/9 Name resolution
If a name does not depend on a template-parameter (as defined in 14.6.2), a declaration (or set of declarations) for that name shall be in scope at the point where the name appears in the template definition; the name is bound to the declaration (or declarations) found at that point and this binding is not affected by declarations that are visible at the point of instantiation.
To put things in simpler terms; if the name is not dependent on a template-parameter it should be in scope where the definition is found; therefore you'll need to define A
before your definition of template
.