我有一个联合体,长这样:
union {
int intValue;
double doubleValue;
std::string stringValue;
void *pointerValue;
} values;
编译时,我收到了这个错误消息(是的,我确实包含了#include <string>
):
./Value.hh:19:19: error: union member 'stringValue' has a non-trivial copy constructor
std::string stringValue;
^
/Developer/SDKs/MacOSX10.7.sdk//usr/include/c++/4.2.1/bits/basic_string.h:434:7: note: because
type 'std::basic_string<char>' has a user-declared copy constructor
basic_string(const basic_string& __str);
^
我使用以下命令进行编译:
$ clang++ *.cc -isysroot /Developer/SDKs/MacOSX10.7.sdk/ -shared
如何在联合体中使用 std::string
?