Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-08-21 07:25:27


From: "David Abrahams" <dave_at_[hidden]>
>
> struct bar {};
> struct foo {
> explicit foo(bar const&);
> };
>
> bar b;
> foo *f = new foo(b); // OK!

Because

foo f(b);

is valid.

> enum baz { x = 444; };
> baz* z = new baz(33); // Error!

Because

baz z(33);

is invalid without a cast.

Functional style casts ("Target(src)") are evil. They look like a
constructor call, but are actually C-style casts in disguise. Even
static_cast<Target>(src) is better than that.

> Hmm, maybe the key here *is* to change my requirements from:
>
> "Target(src)" is valid
>
> to
> "new Target(src)" is valid

Or "Target t(src)" is valid. See

http://std.dkuug.dk/jtc1/sc22/wg21/docs/lwg-active.html#362

for another example of the same problem.


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