@@ -36,10 +36,17 @@ struct NoThrowT {
36
36
NoThrowT (int ) noexcept (true ) {}
37
37
};
38
38
39
- struct AnyConstructible { template <typename T> AnyConstructible (T&&) {} };
40
- struct NoConstructible { NoConstructible() = delete ; };
39
+ struct AnyConstructible {
40
+ template <typename T>
41
+ AnyConstructible (T&&) {}
42
+ };
43
+ struct NoConstructible {
44
+ NoConstructible () = delete ;
45
+ };
41
46
template <class T >
42
- struct RValueConvertibleFrom { RValueConvertibleFrom(T&&) {} };
47
+ struct RValueConvertibleFrom {
48
+ RValueConvertibleFrom (T&&) {}
49
+ };
43
50
44
51
void test_T_ctor_noexcept () {
45
52
{
@@ -59,21 +66,19 @@ void test_T_ctor_sfinae() {
59
66
}
60
67
{
61
68
using V = std::variant<std::string, std::string>;
62
- static_assert (!std::is_constructible<V, const char *>::value, " ambiguous" );
69
+ static_assert (!std::is_constructible<V, const char *>::value, " ambiguous" );
63
70
}
64
71
{
65
- using V = std::variant<std::string, void *>;
66
- static_assert (!std::is_constructible<V, int >::value,
67
- " no matching constructor" );
72
+ using V = std::variant<std::string, void *>;
73
+ static_assert (!std::is_constructible<V, int >::value, " no matching constructor" );
68
74
}
69
75
{
70
76
using V = std::variant<std::string, float >;
71
77
static_assert (!std::is_constructible<V, int >::value, " no matching constructor" );
72
78
}
73
79
{
74
80
using V = std::variant<std::unique_ptr<int >, bool >;
75
- static_assert (!std::is_constructible<V, std::unique_ptr<char >>::value,
76
- " no explicit bool in constructor" );
81
+ static_assert (!std::is_constructible<V, std::unique_ptr<char >>::value, " no explicit bool in constructor" );
77
82
struct X {
78
83
operator void *();
79
84
};
@@ -86,20 +91,13 @@ void test_T_ctor_sfinae() {
86
91
operator X ();
87
92
};
88
93
using V = std::variant<X>;
89
- static_assert (std::is_constructible<V, Y>::value,
90
- " regression on user-defined conversions in constructor" );
94
+ static_assert (std::is_constructible<V, Y>::value, " regression on user-defined conversions in constructor" );
91
95
}
92
96
{
93
97
using V = std::variant<AnyConstructible, NoConstructible>;
94
- static_assert (
95
- !std::is_constructible<V, std::in_place_type_t <NoConstructible>>::value,
96
- " no matching constructor" );
97
- static_assert (!std::is_constructible<V, std::in_place_index_t <1 >>::value,
98
- " no matching constructor" );
98
+ static_assert (!std::is_constructible<V, std::in_place_type_t <NoConstructible>>::value, " no matching constructor" );
99
+ static_assert (!std::is_constructible<V, std::in_place_index_t <1 >>::value, " no matching constructor" );
99
100
}
100
-
101
-
102
-
103
101
}
104
102
105
103
void test_T_ctor_basic () {
@@ -137,15 +135,17 @@ void test_T_ctor_basic() {
137
135
std::variant<RValueConvertibleFrom<int >> v1 = 42 ;
138
136
assert (v1.index () == 0 );
139
137
140
- int x = 42 ;
138
+ int x = 42 ;
141
139
std::variant<RValueConvertibleFrom<int >, AnyConstructible> v2 = x;
142
140
assert (v2.index () == 1 );
143
141
}
144
142
}
145
143
146
144
struct BoomOnAnything {
147
145
template <class T >
148
- constexpr BoomOnAnything (T) { static_assert (!std::is_same<T, T>::value, " " ); }
146
+ constexpr BoomOnAnything (T) {
147
+ static_assert (!std::is_same<T, T>::value, " " );
148
+ }
149
149
};
150
150
151
151
void test_no_narrowing_check_for_class_types () {
0 commit comments