You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// ❌ Can't compile if first type is not default constructible.
253
253
// 💡 Other types don't play a role here.
254
-
int main() { std::variant<NonDefaultConstructibleType, int, double> v; }
254
+
int main() { std::variant<NonDefaultConstructibleType, int, double> v{}; }
255
255
```
256
256
257
257
This code won't compile, throwing an error that tells us that a constructor of the variant is ignored because it does not satisfy the requirement `std::is_default_constructible<NonDefaultConstructibleType>`.
@@ -261,7 +261,7 @@ This code won't compile, throwing an error that tells us that a constructor of t
261
261
262
262
```css
263
263
<source>:7:69: error: no matching constructor for initialization of 'std::variant<NonDefaultConstructibleType, int, double>'
264
-
7 | int main() { std::variant<NonDefaultConstructibleType, int, double> v; }
264
+
7 | int main() { std::variant<NonDefaultConstructibleType, int, double> v{}; }
265
265
| ^
266
266
/cefs/d2/d2e6ebb9fe16525f6e7eb0c3_consolidated/compilers_c++_clang_17.0.1/bin/../include/c++/v1/variant:1326:13: note: candidate template ignored: requirement '__dependent_type<std::is_default_constructible<NonDefaultConstructibleType>, true>::value' was not satisfied [with _Dummy = true]
0 commit comments