Boost logo

Boost Users :

Subject: [Boost-users] [lexical_cast] Fast conversion from boost::iterator_range<std::string::iterator>?
From: Michel Morin (mimomorin_at_[hidden])
Date: 2011-10-13 15:44:07


lexical_cast made optimizations for some types (such as `std::string`)
to achieve better performance. But, from my experience,
it seems that lexical_cast does not make any optimization for
`boost::iterator_range<std::string::iterator>`.

Is there any plan to add optimization for such iterator ranges?
Currently,
  - `lexical_cast<int>(std::string(iter_rng.begin(), iter_rng.end()))`
is faster
    than `lexical_cast<int>(iter_rng)`.
  - Assuming it is safe to use `std::atoi`,
`std::atoi(&iter_rng.front())` is faster
    than both of the above two methods.
(`iter_rng` is an instance of `boost::iterator_range<std::string::iterator>`.)

Regards,
Michel


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