Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2002-08-21 00:48:56


From: "Henrik Ravn" <web_at_[hidden]>

> Hi,
>
> > Finally, there's the issue of default construction. If I want to
> > generically declare a default-constructed object of type T, I
> > can't write:
> >
> > T x;
> >
> > since builtins (and I presume, enums) won't be initialized. I
> > can't write:
> >
> > T x();
> >
> > since that just declares a function. What can/should I write?
>
> You can write:
> T x(T());
>
> which works for every type.

No, that declares a function also. Try this:

struct foo {
private: foo(foo const&);
};

foo x((foo()));

-----------------------------------------------------------
           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