|
Boost Users : |
Subject: Re: [Boost-users] [String_Ref] Working with other parts of boost
From: Antony Polukhin (antoshkka_at_[hidden])
Date: 2013-11-20 03:31:06
2013/11/20 Bjorn Reese <breese_at_[hidden]>
> 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
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