title: Union member has a non-trivial copy constructor
body: <p>I have a union that looks like this:</p>
  
  <pre><code>union {
    int intValue;
    double doubleValue;
    std::string stringValue;
    void *pointerValue;
  } values;
  </code></pre>
  
  <p>When I compile it, I get this error message (yes, I did <code>#include &lt;string&gt;</code>):</p>
  
  <pre><code>./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&lt;char&gt;' has a user-declared copy constructor                              
        basic_string(const basic_string&amp; __str);                                                         
        ^
  </code></pre>
  
  <p>I compile it using this command:</p>
  
  <pre><code>$ clang++ *.cc -isysroot /Developer/SDKs/MacOSX10.7.sdk/ -shared
  </code></pre>
  
  <p>How can I use an <code>std::string</code> in a union?</p>