Boost logo

Boost Users :

From: Michael Marcin (mmarcin_at_[hidden])
Date: 2007-04-19 20:40:06


Paul Moore wrote:
> I hit the same problem that was addressed earlier in these lists
>
> The proposed solution was to juggle around with the internal streams.
>
> The problem with this (it seems to me) is that is leaking the
> implementation into the consumers face.
> We all know that lexical_cast is implemented using streaming in and
> out and thats what makes it pretty lightweight (in terms of the
> amount of code used) but thats no reason to leak the details out.
>
> The other problem is that lexical_cast is really slow; again becuase
> it uses such a general purpose mechanism.
>
> Its seems to me that the class needs specializing
>
> * to bool should accept true and false in any case, or 0 or any
> non-zero int and perhaps yes and no (this is the programmers
> expectation)
> * ints should use atoi and fixed size snprintfs
> * Etc...
>
> the general >> << mechanism is used if there is no specialization
>
> This makes it fast(er) and makes it opaque

I agree.
Not being able to use lexical_cast<bool>( std::string("true") ) certainly
through me.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net