How do you implement strtol under const-correctness? : <p>According to <a href="http://www.cplusplus.com/reference/cstdlib/strtol/">http://www.cplusplus.com/reference/cstdlib/strtol/</a> this function has a signature of <code>long int strtol (const char* str, char** endptr, int base)</code>.</p>

<p>I wonder, though: If it gets passed a <code>const char *</code> to the beginning of the string, how does it manage to turn that into a non-const pointer to the first unprocessed character without cheating? What would an implementation of strtol look like that doesn't perform a const_cast?</p>
