annotate gcc/testsuite/g++.dg/cpp0x/sfinae3.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 // { dg-do compile { target c++11 } }
kono
parents:
diff changeset
2
kono
parents:
diff changeset
3 namespace std { template <class T> T&& declval(); }
kono
parents:
diff changeset
4
kono
parents:
diff changeset
5 template<typename _Tp, typename... _Args>
kono
parents:
diff changeset
6 class is_constructible_mini
kono
parents:
diff changeset
7 {
kono
parents:
diff changeset
8 typedef char __one;
kono
parents:
diff changeset
9 typedef struct { char __arr[2]; } __two;
kono
parents:
diff changeset
10
kono
parents:
diff changeset
11 template<typename _Tp1, typename... _Args1>
kono
parents:
diff changeset
12 static decltype(::new _Tp1(std::declval<_Args1>()...), __one())
kono
parents:
diff changeset
13 __test(int);
kono
parents:
diff changeset
14
kono
parents:
diff changeset
15 template<typename, typename...>
kono
parents:
diff changeset
16 static __two __test(...);
kono
parents:
diff changeset
17
kono
parents:
diff changeset
18 public:
kono
parents:
diff changeset
19 static const bool value = sizeof(__test<_Tp, _Args...>(0)) == 1;
kono
parents:
diff changeset
20 };
kono
parents:
diff changeset
21
kono
parents:
diff changeset
22 /*
kono
parents:
diff changeset
23 template<typename _Tp>
kono
parents:
diff changeset
24 class is_constructible_mini<_Tp>
kono
parents:
diff changeset
25 {
kono
parents:
diff changeset
26 typedef char __one;
kono
parents:
diff changeset
27 typedef struct { char __arr[2]; } __two;
kono
parents:
diff changeset
28
kono
parents:
diff changeset
29 template<typename _Tp1>
kono
parents:
diff changeset
30 static decltype(::new _Tp1, __one()) __test(int);
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 template<typename>
kono
parents:
diff changeset
33 static __two __test(...);
kono
parents:
diff changeset
34
kono
parents:
diff changeset
35 public:
kono
parents:
diff changeset
36 static const bool value
kono
parents:
diff changeset
37 = sizeof(__test<typename std::remove_cv<_Tp>::type>(0)) == 1;
kono
parents:
diff changeset
38 };
kono
parents:
diff changeset
39 */
kono
parents:
diff changeset
40
kono
parents:
diff changeset
41 struct A
kono
parents:
diff changeset
42 {
kono
parents:
diff changeset
43 A(int);
kono
parents:
diff changeset
44 };
kono
parents:
diff changeset
45
kono
parents:
diff changeset
46 struct B { };
kono
parents:
diff changeset
47
kono
parents:
diff changeset
48 static_assert( is_constructible_mini<A, int>::value, "");
kono
parents:
diff changeset
49 static_assert( is_constructible_mini<A, A>::value, "");
kono
parents:
diff changeset
50 static_assert( !is_constructible_mini<A, int, double>::value, "");
kono
parents:
diff changeset
51
kono
parents:
diff changeset
52 static_assert( !is_constructible_mini<A>::value, ""); // doesn't compile without the
kono
parents:
diff changeset
53 // partial specialization
kono
parents:
diff changeset
54
kono
parents:
diff changeset
55 static_assert( is_constructible_mini<B>::value, "");
kono
parents:
diff changeset
56 static_assert( is_constructible_mini<const B>::value, "");