Boost logo

Boost :

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

"Fernando Cacciola" <fcacciola_at_[hidden]> wrote in message
> 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

> 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

> I don't know about incomplete types.
> In my view, T* is not an incomplete type; it is a perfectly complete type
> pointer type.
> If I put a pointer to T in a discriminated union, I want the 'pointer',
> 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
> 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.


Boost list run by bdawes at, gregod at, cpdaniel at, john at