
On May 12, 2005, at 8:59 AM, Kevlin Henney wrote:
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.
Unfortunately, writing a performance centric convert_to is not a load I want to carry. For me, the lexical_cast and hence stream-based performance is just fine for our app. All I want is a default value without littering my code with try/catch statements (of if statements, even). For now, I'm just going to patch my version of lexical_cast.hpp with my original patch or maybe move that to an external header that relies on the Boost internals. We don't mind if it doesn't quite look like a cast. I guess for us, no try/catch statements trumps quasi-cast semantics and non-optimal performance. If someone wants to tackle a performance centric convert_to or string_to, lemme know and I'll test it, but I'm not going to push this issue any more. -Dave