Re: lexical_cast question
by Tom Matelich other posts by this author
Sep 27 2001 7:20PM messages near this date
Re: [boost] Re: lexical_cast question
|
Re: [boost] Polymorphic Iterators
--- In boost@[...].. , Kevlin Henney <kevlin@[...]..> wrote:
> 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
Have you gotten anywhere on this Kevlin? I got bit by passing in an
empty string yesterday and it really made me wish for a string to
string specialization (overload?).
Thread:
Vladimir Prus
Thomas Matelich
Kevlin Henney
Tom Matelich
Larry Evans
Steven Kirk
Kevlin Henney
|