Re: lexical_cast question
by Vladimir Prus other posts by this author
Feb 22 2001 12:24PM messages near this date
Re: [boost] Status dir_it lib
|
Re: [boost] Re: lexical_cast question
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.
2. Change will add functionality, and is *very* unlikely to break anything.
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. lexical_cast knows
that exactly one object was put there, so why should we pretend we don't know
that?
> 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?
--
Regards,
Vladimir
Thread:
Vladimir Prus
Thomas Matelich
Kevlin Henney
Tom Matelich
Larry Evans
Steven Kirk
Kevlin Henney
|