boostorg / describe

A C++14 reflection library
https://boost.org/libs/describe
67 stars 24 forks source link

Support for unions #21

Closed pdimov closed 2 years ago

pdimov commented 2 years ago

BOOST_DESCRIBE_STRUCT and BOOST_DESCRIBE_CLASS reject unions with a static_assert, but they shouldn't.

However, once unions are allowed, all the examples need an is_class check added, because traversing all the described members of a union is guaranteed undefined behavior (because at most one is active.)

https://lists.boost.org/Archives/boost/2021/11/252270.php

pdimov commented 2 years ago

The prototype implementation of the Reflection TS supports unions: https://compiler-explorer.com/z/q9TEGE598