1 // Testcase from P0512R0 for C++17 NB comment US 19
2 // { dg-do compile { target c++17 } }
3 
4 template<typename> struct remove_ref;
5 template<typename _Tp> struct remove_ref { typedef _Tp type; };
6 template<typename _Tp> struct remove_ref<_Tp&> { typedef _Tp type; };
7 template<typename _Tp> struct remove_ref<_Tp&&> { typedef _Tp type; };
8 template<typename _Tp> using remove_ref_t = typename remove_ref<_Tp>::type;
9 
10 template<class T> struct A {
11  A(T, int*); // #1
12  A(A<T>&, int*); // #2
13  enum { value };
14 };
15 template<class T, int N = remove_ref_t<T>::value> A(T&&, int*) -> A<T>; //#3
16 
17 A a{1,0}; // uses #1 to deduce A<int> and initializes with #1
18 A b{a,0}; // uses #2 to deduce A<int> and initializes with #2
19 
20 template <class,class> struct same;
21 template <class T> struct same<T,T> {};
22 
23 same<decltype(a),A<int>> s1;
24 same<decltype(b),A<int>> s2;
25