title: Is it possible to save data natively from a string which is destructed afterwards without moving it elsewhere?
body: <pre><code>const char* s = std::string("text").c_str();
  std::cout &lt;&lt; s &lt;&lt; std::endl; //This will print nothing because the data
                               //isn't available any longer
  </code></pre>
  
  <p><code>std::string::c_str()</code> returns a pointer to its stored data.
  Considering the fact that <code>std::string("text")</code> is just available for the time I use it (e.g. when I use it to initialize another instance) so in the end the destructor is called which deletes the data which, in turn, makes <code>s</code> pointing to nothing.</p>
  
  <p>Now my question is if there is a native (library-independent) way to keep the raw data alive. Or is it just possible if they would use something like a shared-smart-pointer which knows if something else is pointing to the <code>std::string</code>'s data so it is not deleted yet.</p>