遇到一个union里面放一些非基本类型编译不通过的问题,查了一下得到如下解释
Current C++ standard does not allow non-POD types inside unions. Hence you get this compiler error from gcc.
Instead of using C unions, you should use boost::variant. Check the doccumentationhere.
To add to the above:
The new C++ standard(C++0x) adds a new feature called as Unrestricted Unions, which supports storing non-POD types to a Union.
本文探讨了C++标准中关于union使用的基本类型限制,并介绍了如何使用boost::variant替代。此外,还提到了C++0x标准引入的Unrestricted Unions特性,允许在union中存放非POD类型。

4628

被折叠的 条评论
为什么被折叠?



