
On Tue, May 11, 2010 at 4:12 PM, John Dlugosz
How about making explicit specializations of lexical_cast that would be faster than the general implementation? That way the optimization is invisible.
Nevermind optimizations, I think that a simple function call is easier to use and more practical: std::string x=to_string(y). Lexical_cast is in a different domain altogether IMO, plus it has other issues, for example it can't use ADL.
Emil Dotchevski
hitting dictionary.com ... Anti-Defamation League? Activities of Daily Living?
Argument-dependent look-up, but I'm sure that's not on dictionary.com :)
I like the idea of defining operator<< and being done with it.
The problem is that op<< needs a std::ostream, and that's not convenient when you want to convert something to string. However, calling op<< is a good default behavior for a generic to_string function template.
If it's an explicit specialization, lexical_cast<string> is just another spelling for to_string.
No, the important semantic difference is that lexical_cast<string> can not use ADL. However, it could be a good idea to write a generic lexical_cast<string> that resolves to a unqualified call to to_string. Emil Dotchevski Reverge Studios, Inc. http://www.revergestudios.com/reblog/index.php?n=ReCode