
In message <427A7A31.8000504@simplexsoft.com>, Andrey Melnikov <melnikov@simplexsoft.com> writes
The purpose of lexical cast is conversion through serializaton and deserialization. boost::lexical_cast is called lexical cast because it uses STL object serialization framework based on << and >> operators.
Semantically convert_to is a different operation.
[...]
I think we can leave lexical_cast alone as it is, but add separate functions for safe conversions between ascii and binary representation of numbers. These functions should be fast and properly named according to their semantic. Performance requirement can also force us to implement additional interface with error flag instead of throwing exceptions. convert_to<int>("abc") can be so fast that in some applications overhead of throwing an exception will be very noticeable.
I think that the specialisation (conceptual as opposed to templated) perspective is the right way to go. lexical_cast caters for a general need, but not all specific needs (it is stream-based and not performance-centric), so functions that cater to more specific conversions -- convert_to with default, string_to, etc -- seem to make sense. It is not a load that lexical_cast should be carrying all of, IMHO. Kevlin -- ____________________________________________________________ Kevlin Henney phone: +44 117 942 2990 mailto:kevlin@curbralan.com mobile: +44 7801 073 508 http://www.curbralan.com fax: +44 870 052 2289 Curbralan: Consultancy + Training + Development + Review ____________________________________________________________