Debian Codegraph @

gcc/testsuite/g++.dg/template/defarg23a.C

raw
1 // PR c++/65396
2 // { dg-do compile { target c++11 } }
3 // Like defarg23.C, but for member functions.
4
5 struct A {
6 template<class T> void f();
7 template<class T=int> void g(); // { dg-message "original definition" }
8 template<class T=char, class U> void h();
9 };
10
11 template<class T=int> void A::f() { }
12 template<class T=int> void A::g() { } // { dg-error "redefinition of default" }
13 template<class T, class U=bool>
14 void A::h() {
15 static_assert(__is_same(T, char), "");
16 static_assert(__is_same(U, bool), "");
17 }
18
19 int main() {
20 A a;
21 a.f();
22 a.g();
23 a.h();
24 }