Summary
This episode explores the capabilities and limitations of using std::optional and std::variant in constexpr contexts in C++17. Jason clarifies that while these algebraic data types can be used in constexpr contexts, they have some limitations: they cannot be reassigned within a constexpr context, although they can be constructed, accessed, and checked for values. The episode also identifies a potential implementation bug in GCC's standard library that incorrectly allows reassignment in constexpr contexts.
Related C++ Standard Sections
This episode covers topics found in these sections of the C++ standard:
-
[dcl.constexpr]71% match -
[depr.static.constexpr]67% match -
[constexpr.functions]63% match -
[variant.status]53% match -
[diff.cpp11.dcl.dcl]52% match