annotate gcc/testsuite/g++.dg/cpp1z/class-deduction26.C @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 // Testcase from P0512R0 for C++17 NB comment US 20
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2 // { dg-do compile { target c++17 } }
111
kono
parents:
diff changeset
3
kono
parents:
diff changeset
4 template <class,class> struct same;
kono
parents:
diff changeset
5 template <class T> struct same<T,T> {};
kono
parents:
diff changeset
6
kono
parents:
diff changeset
7 template<class T> struct A {
kono
parents:
diff changeset
8 template<class U>
kono
parents:
diff changeset
9 A(T&&, U&&, int*); // #1: T&& is not a forwarding reference
kono
parents:
diff changeset
10 // U&& is a forwarding reference
kono
parents:
diff changeset
11 A(T&&, int*); // #2
kono
parents:
diff changeset
12 };
kono
parents:
diff changeset
13 template<class T>
kono
parents:
diff changeset
14 A(T&&, int*) -> A<T>; // #3: T&& is a forwarding reference
kono
parents:
diff changeset
15
kono
parents:
diff changeset
16 int i;
kono
parents:
diff changeset
17 int *ip;
kono
parents:
diff changeset
18 A a0{0, 0, ip}; // uses #1 to deduce A<int> and #1 to initialize
kono
parents:
diff changeset
19 same<decltype(a0),A<int>> s1;
kono
parents:
diff changeset
20 A a2{i, ip}; // uses #3 to deduce A<int&> and #2 to initialize
kono
parents:
diff changeset
21 same<decltype(a2),A<int&>> s2;
kono
parents:
diff changeset
22
kono
parents:
diff changeset
23 A a{i, 0, ip}; // { dg-error "" } cannot deduce from #1