2013/11/20 Bjorn Reese <breese@mail1.stofanet.dk>
On 11/19/2013 04:26 PM, Norbert Wenzel wrote:

I'm not sure if I understand your point correctly, but lexical_cast was
the one thing I used, which actually did work with string_ref. Though I
didn't check if lexical_cast made any copies or other unnecessary stuff
internally, but I think I got the correct results from lexical_cast.

You are right. lexical_cast does work with string_ref.

I overlooked the fact that lexical_cast works with both pointer+size
and iterator_range ranges.

More specifically, I overlooked the fact that lexical_cast uses
string_ref::operator<< to obtain the data (and I guess that this is
why Boost.Spirit generally outperforms lexical_cast.)

There is a plan to add optimizations for string_ref to lexical_cast so there'll be minimal difference in performance.

Boost.Spirit and Boost.LexicalCast differ not only in performance: lexical_cast is more precise when working with real numbers and uses std::locale during conversions to be able to process decimal and other separators in a locale dependent way. LexicalCast is also usable with user-defined types that have operator>> and operator<< overloads. So choose tool depending on your needs.

--
Best regards,
Antony Polukhin