On using constexpr
and unions, with insights into the design of the currently-proposed std::optional<T>
:
Constexpr Unions
by Andrzej Krzemieński
I assume you are already familiar with
constexpr
functions. (If not, see a short introduction here.) [Ed.: We linked to that article recently, so you've seen it if you've been following isocpp.org.]In this post I wanted to share my experience with using unions in constant expressions. Unions are not very popular due to type-safety hole they open, but they offer some capabilities that I found priceless when working with Fernando Cacciola on
std::optional
proposal.
Add a Comment
Comments are closed.