std::string as C++ byte array
<p>Google's Protocol buffer uses the C++ standard string class <code>std::string</code> as variable size byte array (<a href="http://code.google.com/apis/protocolbuffers/docs/proto.html#scalar" rel="nofollow">see here</a>) similar to Python where the string class is also used as byte array (at least until Python 3.0).</p>

<p>This approach seems to be good:</p>

<ul>
<li>It allows fast assignment via <a href="http://www.cplusplus.com/reference/string/string/assign/" rel="nofollow"><code>assign</code></a> and fast direct access via <a href="http://www.cplusplus.com/reference/string/string/data/" rel="nofollow"><code>data</code></a> that is not allowed with <code>vector&lt;byte&gt;</code></li>
<li>It allows easier memory management and const references, unlike using <code>byte*</code>.</li>
</ul>

<p>But I am curious: Is that the preferred way for a byte arrays in C++? What are the drawbacks of this approach (more than a few <code>static_cast</code>s) </p>
