title: Should a std::string class member be a pointer?
body: <p>And why/why not?</p>
  
  <p>Say I have a class which takes a string in the constructor and stores it. Should this class member be a pointer, or just a value?</p>
  
  <pre><code>class X {
      X(const std::string&amp; s): s(s) {}
      const std::string s;
  };
  </code></pre>
  
  <p>Or...</p>
  
  <pre><code>class X {
      X(const std::string* s): s(s) {}
      const std::string* s;
  };
  </code></pre>
  
  <p>If I was storing a primitive type, I'd take a copy. If I was storing an object, I'd use a pointer.</p>
  
  <p>I feel like I <em>want</em> to copy that string, but I don't know when to decide that. Should I copy vectors? Sets? Maps? Entire JSON files...?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Sounds like I need to read up on move semantics. But regardless, I'd like to make my question a little more specific:</p>
  
  <p>If I have a 10 megabyte file as a const string, I really don't want to copy that.</p>
  
  <p>If I'm newing up 100 objects, passing a 5 character const string into each one's constructor, none of them ought to have ownership. Probably just take a copy of the string.</p>
  
  <p>So  (assuming I'm not completely wrong) it's obvious what to do from <em>outside</em> the  class, but when you're designing <code>class GenericTextHaver</code>, how do you decide the method of text-having?</p>
  
  <p>If all you need is a class that takes a const string in its constructor, and allows you to get a const string with the same value <em>out</em> of it, how do  you decide how to represent it internally?</p>