Boost logo

Boost :

From: Douglas Gregor (gregod_at_[hidden])
Date: 2002-06-18 19:47:36


On Friday 14 June 2002 12:13 am, Andrei Alexandrescu wrote:
> Direct recursion would be *very* desirable. I could enable it in a
> couple of limited instances, but unfortunately not in the general
> case.
>
> The classic example is when you want to define a tree. A binary tree
> node is either a leaf or a pair of tree nodes:
>
> typedef Variant<TYPELIST_2(Leaf, std::pair<Self*, Self*>)>
> TreeNode;
>
>
> Andrei

I see that we didn't all agree on the meaning of 'direct recursion'. I see
absolutely no reason to allow:

  typedef variant<int, double, rec> some_type;

where 'rec' is replaced with 'some_type' by the variant implementation. It's
just not useful for a variant type to contain itself.

I do see the motivation for recursive types as in your binary tree example.
However, the implementation of this support is likely to be long and too
complex for quite a few existing C++ compilers. I'd be interested to
recursive types so long as a #define can factor out the support so that
variant types aren't useless on near-useless compilers.

        Doug


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