Marshalling managed string from class member
<p>Using <code>marshal_cppstd.h</code> and <code>msclr::interop::marshal_as&lt;&gt;</code> I can marshal a managed string to <code>std::string</code> like this:</p>

<pre><code>String^ managed = "test";
std::string unmanaged = marshal_as&lt;std::string&gt;(managed);
</code></pre>

<p>Now when <code>managed</code> is a member of the class I am writing code in, I get an error when doing simply this:</p>

<pre><code>std::string unmanaged = marshal_as&lt;std::string&gt;(this-&gt;managed);
</code></pre>

<p>The error says:</p>

<blockquote>
  <p>no instance of overloaded function "marshal_as" matches the argument list</p>
</blockquote>

<p>Or as compiler error C2665:</p>

<blockquote>
  <p>'msclr::interop::marshal_as': none of the 3 overloads could convert all the argument types</p>
</blockquote>

<p>When I change the code to use a helper variable, it works:</p>

<pre><code>String^ localManaged = this-&gt;managed;
std::string unmanabed = marshal_as&lt;std::string&gt;(localManaged);
</code></pre>

<p>There must be some implicit casting here, isn't it? Why does this happen and how I can make the simple one-liner work?</p>