Boost logo

Boost Users :

Subject: Re: [Boost-users] Recursive variant problem
From: Larry Evans (cppljevans_at_[hidden])
Date: 2010-07-07 13:53:08


On 07/07/10 09:53, Timothy Madden wrote:
> Hi
>
> I use the following type in my application:
>
> boost::make_recursive_variant
> <
> boost::tuple
> <
> std::basic_string<TCHAR>, // id
> std::basic_string<TCHAR>, // name
> std::basic_string<TCHAR>, // desc
> std::basic_string<TCHAR>, // type
> std::basic_string<TCHAR>, // value
> std::vector<boost::recursive_variant_> // childList
> >
> >::type
>
> However when I instantiate it and I try to populate (resize) the vector
> (member indexed 5 in the tuple, childList) I get:
> 'boost::recursive_variant_' : class has no constructors
> from Visual Studio 2008 SP1.
>
> It looks like the boost::recursive_variant_ type is not substituted with
> the type of the enclosing variant by the make_recursive_variant
> meta-function. Am I missing something ? Is this is bug ?
>
> I have also tried adding some more members to the variant, with no success.
>
> Thank you,
> Timothy Madden
Maybe you could just use pointers to the enclosing composite, like in:

#include <tr1/tuple>
#include <vector>

struct tuple_tree
: std::tr1::tuple
   < float
   , int
   , std::vector<tuple_tree*>
>
{
};

int main(void)
{
     tuple_tree tt;
     std::vector<tuple_tree*>&children=std::tr1::get<2>(tt);
     children.push_back(new tuple_tree);
     return std::tr1::get<1>(tt);
}


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net