Boost logo

Boost Users :

From: Gennadiy Rozental (gennadiy.rozental_at_[hidden])
Date: 2005-01-18 17:22:03


> 1. lexical_cast(Source arg) takes the source argument by value. Why not
> by const& ? Calling lexical_cast(some_basic_string) now makes a copy of
> the source argument for no reason.

There numerous optimization/enhancements that could be done to lexical_cast.
In my version I use different interpretators, type wrappers, specializations
e.t.c. And still in my recent study I found that lexical_cast ~ 20 times
slower then sprintf and ~200 times slower then my own handcrafted version
for decimal integer parcing. Conclusion: do NOT use lexical_cast in
performance critical (even performance aware) parts of your code. The only
place where I use it is during initialization. Accordingly no need to bother
about reverence vs. value semantic.

> 2. lexical_cast ignores trailing whitespaces, but not leading
> whitespaces. Meaning that

My recomendation is: trim the value on both sodes before cast. And do not
rely on lexical cast to detect your whitespaces.

> Thanks,
> Yuval

HTH,

Gennadiy


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