What if I have this:
union{
vector intVec ;
vector floatVec ;
vector doubleVec ;
} ;
Of cours
Current C++ standard does not allow non-POD types inside unions. You will get this compiler error from gcc
:
error: member ‘std::vector >
::i’ with constructor not allowed in union
error: member ‘std::vector >
::i’ with destructor not allowed in union
New C++ standard (C++0x) proposes unrestricted unions, but it adds yet more object lifetime pitfalls to C++.