Re: [boost] Re: lexical_cast question
by Kevlin Henney other posts by this author
Feb 26 2001 7:32AM messages near this date
Re: [boost] Re: lexical_cast question
|
Re: lexical_cast question
In message <01022215243600.04969@[...]..> , Vladimir Prus
<ghost@[...]..> writes
> Kevlin Henney wrote:
>
> >>At the moment lexical_cast<string>(whatever) will fail if 'whatever'
> decides
> >>to insert spaces in its representation. I think that it is not very
> >>convenient.
>
> >You're right that it's not convenient, but I would hesitate to make
> >std::string a special case.
>
> I really think that making std::string a special case is OK, because:
> 1. It will always be a special case, either inside lexical_cast or in user
> code.
I was referring to std::string as a special case of std::basic_string,
but that's something that can be accommodated without a problem, and
also to other string classes. However, in the latter case if the 'API'
is opened up, that offers a hook for extension.
> 3. Actually, string's operator>> has no choice but to stop when it encounters
> space, for it has no knowledge what was put in the stream.
Well, it does have a choice, but that's a historical design decision we
can't easily retake :->
> > A more general solution would be to replace the expression
>
> > ... || !(interpreter >> result) || ...
>
> > by
>
> > ... || !interpret(interpreter, result) || ...
>
> Yes, this is shurely better. What are chances that something like this will
> be added?
High :-) When I get a moment I will try to roll this change in with the
proposed floating point mods, plus tests and changes to docs.
Kevlin
____________________________________________________________
Kevlin Henney phone: +44 117 942 2990
Curbralan Limited mobile: +44 7801 073 508
mailto: kevlin@[...].. fax: +44 870 052 2289
http://www.curbralan.com
____________________________________________________________
Thread:
Vladimir Prus
Thomas Matelich
Kevlin Henney
Tom Matelich
Larry Evans
Steven Kirk
Kevlin Henney
|