Boost logo

Boost :

Subject: Re: [boost] [review] string convert
From: Stewart, Robert (Robert.Stewart_at_[hidden])
Date: 2011-05-06 08:00:55


Vladimir Batov wrote:
>
> I am glad you mentioned "lexical" and "conversion" together as
> that's exactly how I see lexical_cast which pretends to be a
> cast when it is not (and I do not like pretenders). It's a
> converter -- it returns a completely new instance of a
> different type when a cast returns the same instance but
> retyped (I am aware that upcast returns a different pointer
> instance for multiple inheritance).

You have quite a mistaken notion about casts. static_cast<int>(1.235) returns an int. It does not return the double 1.235 retyped as int. lexical_cast is not pretending to be a cast. It *is* a cast.

> So, I am not thrilled by the latest attempts to continue that
> pretending business with convert_cast name (not to mention it
> is an oxymoron -- convert and cast are quite different
> operations).

convert_cast does a proper cast. Conversion and casting are different shades of the same color. Consider static_cast<int>(1.235), which involves a conversion:

"4.9 Floating-integral conversions

1 An rvalue of a floating point type can be converted to an rvalue of an integer type."

_____
Rob Stewart robert.stewart_at_[hidden]
Software Engineer using std::disclaimer;
Dev Tools & Components
Susquehanna International Group, LLP http://www.sig.com

IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk