String (const char*, size_t) to int?
<p>What's the fastest way to convert a string represented by (const char*, size_t) to an int?</p>

<p>The string is <em>not</em> null-terminated.
Both these ways involve a string copy (and more) which I'd like to avoid.</p>

<p>And yes, this function is called a few million times a second. :p</p>

<pre><code>int to_int0(const char* c, size_t sz)
{
    return atoi(std::string(c, sz).c_str());
}

int to_int1(const char* c, size_t sz)
{
    return boost::lexical_cast&lt;int&gt;(std::string(c, sz));
}
</code></pre>
