Но при совокупной инициализации анонимные союзы могут существовать в инициализированном агрегате, и первый член профсоюза будет инициализирован.
Код: Выделить всё
enum class A {};
enum class B {};
enum class C {};
enum class D {};
struct S {
A a;
union {
B b;
C c;
};
D d;
};
// Aggregate initialization initializes first anonymous union member b
S s{ A{}, B{}, D{} };
// Does not work -- why not extract b like aggregate initialization of b?
auto& [a, b, d] = s;
Подробнее здесь: https://stackoverflow.com/questions/796 ... o-how-they