Boost logo

Boost :

From: Douglas Gregor (gregod_at_[hidden])
Date: 2002-06-13 22:37:43


On Thursday 13 June 2002 07:54 pm, Itay Maman wrote:
> 2. Is direct recursion (i.e: variant<int, rec>) allowed?
> I think we should not allow instantiations like this:
> variant<int, rec> v1;

Direct recursion seems to cause more headaches than it fixes problems.

> As for the storage policy, I do find it is useful (to the same extent as
> allocators...) but I am willing to drop that as well on practical
> grounds: (1)
> It will only be used in extremely rare cases. (2) Combining a default
> template
> parameter with a non type-list interface will (unjustifably) complicate
> variant's Instantiation interface.

(1) I agree with, although I still slightly favor having an 'incomplete' or
'heap' designator to ask for heap storage (so we can store recursive types
without going through the hassle of new'ing and dereferencing a smart
pointer).

If we wanted, e.g., an allocator for the heap allocations we could use a named
template parameters approach. Then again, allocators aren't used all that
often, and heap allocation only happens at the user's request anyway.

> The conversion behavior should use overload resolution rules.
>
>
> 4. Instantiation interface
> We should support both options, i.e:
>
> template<
> typename T1, typename T2 = Unused_tag, typename, T3 =
> unused_tag,...>
> class variant;
>
> - and -
>
> template<typename H, typename T>
> class variant<TypeList<H,T> >;
>
>
> In either option, variant's internal implementation should be
> TypeLists-based.

We might run into practical portability problems using a purely typelist-based
implementation along with overload resolution for conversions & assignments.
I'll be gone for a few days without 'net access to continue bickering about
semantics :), but I'll try to catch up with the discussion when I get back.

        Doug


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