|
Boost : |
From: Thomas Witt (witt_at_[hidden])
Date: 2002-05-25 03:27:05
On Saturday 25 May 2002 09:14, Mattias Flodin wrote:
> On Sat, May 25, 2002 at 03:37:57AM +0200, Terje Slettebø wrote:
> >
> > What I'm wondering is, is it ok to perform the conversion as in the
> > latter case (implicit conversion)? I would think it would be ok, and make
> > the conversion more flexible, as it takes into account implicit
> > conversions, but as it's a change in the semantics from the original
> > lexical_cast, I'd like to get feedback on this.
>
> At first sight, this seems to me like something that would go under
> the category "implementation defined" or "undefined behaviour,"
Having such a fundamental thing implementation defined is asking for trouble.
> since
> trying to do a lexical cast between two "non-lexical" types is rather
> nonsensical. Either you cast from text, to text, or both.
I strongly disagree. Conceptually lexical_cast converts between types that
have a textual representation, in c++ speak have suitable operator>><<
overloads. Implicit conversion are a different concept. That said,
lexical_cast<int>(1.23) should _always_ be an error.
Thomas
-- Dipl.-Ing. Thomas Witt Institut fuer Verkehrswesen, Eisenbahnbau und -betrieb, Universitaet Hannover voice: +49(0) 511 762 - 4273, fax: +49(0) 511 762-3001 http://www.ive.uni-hannover.de
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk