Boost logo

Boost :

Subject: Re: [boost] [variant] awkward recursion
From: Dave Abrahams (dave_at_[hidden])
Date: 2012-10-30 10:16:12

on Mon Oct 29 2012, Mathias Gaunard <> wrote:

> On 29/10/12 22:33, Dave Abrahams wrote:
>> on Mon Oct 29 2012, Mathias Gaunard <> wrote:
>>> On 29/10/12 20:29, Dave Abrahams wrote:
>>>> Using recursive_variant_ works out quite nicely, except that
>>>> it doesn't allow me to separately declare "object" and "array" and
>>>> re-use them in the definition of "value":
>>>> typedef boost::make_recursive_variant<
>>>> null
>>>> , std::string
>>>> , double
>>>> , std::map<std::string, boost::recursive_variant_>
>>>> , std::vector<boost::recursive_variant_>
>>>> , bool
>>>> >::type value;
>>> I'd use this method, it's clearly the cleanest.
>>> I don't understand what's your problem with it.
>> As I had feared, and as
>> demonstrates, extra dynamic allocations will be used to store maps and
>> vectors (or anything at all?) in the variant.

I should also point out that it might be putting the indirection in the
"wrong" place. having the recursive_wrapper around the whole map or
vector is clearly more efficient than having it around (part of) their

> Why not fix the implementation then instead of writing hacks?

I realized it's not completely fixable as Steven points out. I actually
did think of trying to do something about other issues,, but...

> Of course, the code of variant is horrible enough to make it very
> difficult to do anything with it.


Dave Abrahams
BoostPro Computing                  Software Development        Training             Clang/LLVM/EDG Compilers  C++  Boost

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