Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2002-08-21 07:13:02


From: "Peter Dimov" <pdimov_at_[hidden]>

> From: "David Abrahams" <dave_at_[hidden]>
> >
> > I'm not sure what problem you're trying to solve, but open problem is:
> >
> > "Given a type T with an explicit conversion from U and an object of
type
> U,
> > how do I [placement] new a T"?
>
> new T(u);
>
> unless you are counting C-style casts as explicit conversions, i.e.
>
> typedef char * U;
>
> int const i;
>
> U(&i); // works but do you really want that?

struct bar {};
struct foo {
   explicit foo(bar const&);
};

bar b;
foo *f = new foo(b); // OK!

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

So, a C-style cast may look syntactically identical to an explicit
conversion, but still might be different?

Hmm, maybe the key here *is* to change my requirements from:

    "Target(src)" is valid

to
    "new Target(src)" is valid

But that still leaves me with an uneasy feeling that something's amiss with
the language definition (what's new?)

-Dave

-----------------------------------------------------------
           David Abrahams * Boost Consulting
dave_at_[hidden] * http://www.boost-consulting.com


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