我有一个POD结构,但为方便起见,我希望它有std::initializer_list
ctor。默认ctor,copy ctor和dtor是隐含的。然而,似乎使用initializer_list
ctor取消了结构作为POD的资格,因此它不能在联盟中:
#include<initializer_list>
struct A{
A(const std::initializer_list<int>&);
};
union{
A a;
} a;
gcc 4.6 --std = c ++ 0x:
error: use of deleted function ‘<anonymous union>::._0()’
error: ‘<anonymous union>::._0()’ is implicitly deleted because the default definition would be ill-formed:
error: no matching function for call to ‘A::A()’
周围有它吗?它与c ++ 11的无限制联合功能有关吗?