title: Can std::string::c_str() be used whenever a string literal is expected?
body: <p>I would guess that the last two lines in this code should compile.</p>
  
  <pre><code>#include "rapidjson/document.h"
  
  int main(){
      using namespace rapidjson ;
      using namespace std ;
  
      Document doc ;
      Value obj(kObjectType) ;
      obj.AddMember("key", "value", doc.GetAllocator()) ; //this compiles fine
      obj.AddMember("key", string("value").c_str(), doc.GetAllocator()) ; //this does not compile!
  }
  </code></pre>
  
  <p>My guess would be wrong, though. One line compiles and the other does not.</p>
  
  <p>The <code>AddMember</code> method has several variants as documented <a href="http://rapidjson.org/classrapidjson_1_1_generic_value.html" rel="nofollow noreferrer">here</a>, but beyond that... why is the return of <code>.c_str()</code> not equivalent to a string literal? </p>
  
  <p>My understanding was that where ever a string literal was accepted, you could pass <code>string::c_str()</code> and it should work.</p>
  
  <p>PS: I'm compiling with VC++ 2010.</p>
  
  <p><strong>EDIT:</strong><br>
  The lack of <code>#include &lt;string&gt;</code>  is not the problem. It's already included by <code>document.h</code></p>
  
  <p><strong>This is the error:</strong></p>
  
  <pre><code>error C2664: 'rapidjson::GenericValue&lt;Encoding&gt; &amp;rapidjson::GenericValue&lt;Encoding&gt;::AddMember(rapidjson::GenericValue&lt;Encoding&gt; &amp;,rapidjson::GenericValue&lt;Encoding&gt; &amp;,Allocator &amp;)'
  : cannot convert parameter 1 from 'const char [4]' to 'rapidjson::GenericValue&lt;Encoding&gt; &amp;'
      with
      [
          Encoding=rapidjson::UTF8&lt;&gt;,
          Allocator=rapidjson::MemoryPoolAllocator&lt;&gt;
      ]
      and
      [
          Encoding=rapidjson::UTF8&lt;&gt;
      ]
  </code></pre>
  
  <hr>
  
  <p><strong>EDIT2:</strong><br>
  Please ignore the fact that <code>.c_str()</code> is called on a temporal value. This example is just meant to show the compile error. The actual code uses a string variable.</p>
  
  <hr>
  
  <p><strong>EDIT3:</strong><br>
  Alternate version of the code:</p>
  
  <pre><code>string str("value") ;
  obj.AddMember("key", "value", doc.GetAllocator()) ; //compiles
  obj.AddMember("key", str, doc.GetAllocator()) ; // does not compile
  obj.AddMember("key", str.c_str(), doc.GetAllocator()) ; // does not compile
  </code></pre>