Boost logo

Boost :

From: Andrei Alexandrescu (andrewalex_at_[hidden])
Date: 2002-06-12 16:32:05


"Fernando Cacciola" <fcacciola_at_[hidden]> wrote in message
news:005e01c21219$b35268c0$0f00a8c0_at_fernandoc...
> I'm not even sure if we *need* heap allocation (see below). If we don't
> *need* it, I'll vote for stack-allocation only.

I agree. Use the tool for the job. You can use Variant with smart pointers,
because it is very likely Variant would use a smart-pointer-like mechanism
inside anyway. So now you have the richness of smart_ptr combined with
Variant.

> I agree that a variant should be implicitely convertible to any of its
> types.

I disagree. If the conversion fails, an exception is thrown. The idea of
having a silent, implicit, operation throwing an exception would be best
avoided.

> I don't know about incomplete types.
> In my view, T* is not an incomplete type; it is a perfectly complete type
of
> pointer type.
> If I put a pointer to T in a discriminated union, I want the 'pointer',
not
> the 'T' instance, to be represented by the union.
> That is, the union deals with the pointer value only; to whatever it is
> pointing to, and how that is allocated, is IMO, totally unrelated.
> I don't think there is a really good reason to have a truly-incomplete
type
> in an union.

I believe the same. There is this tension: a Variant would ideally use
in-situ allocation, but that's not possible with incomplete types.

Andrei


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