Boost logo

Boost Users :

Subject: Re: [Boost-users] Recursive variant problem
From: Timothy Madden (terminatorul_at_[hidden])
Date: 2010-07-08 03:11:36


Larry Evans wrote:

> 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 ?
[...]
> 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*>
> >
> {
> };

I can use vector<tuple_tree> directly, with no pointer needed, and it
works, but I would expect boost::make_recursive_variant<> to do the
substitution correctly so I could create the type in-place.

This structure is part of a bigger tuple of containers in my code, and
using tuple_tree would require me to declare it in advance, separately,
while make_recursive_variant would create the needed type in-place.

Here is my code:

class UIOVarEntry:
public
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<UIOVarEntry> // childList
>
{
};

typedef
boost::tuple
   <
     int, // serviceID
     int, // projectID
     int, // version
     std::basic_string<TCHAR>, // htmlData,
     std::basic_string<TCHAR>, // uioDesignData
     std::vector
       <
         boost::tuple
           <
             bool, // isGroup
             std::basic_string<TCHAR>, // uuid
             int, // version
             std::basic_string<TCHAR>, // parentID
             std::basic_string<TCHAR>, // prevID
             std::basic_string<TCHAR>, // name,
             std::basic_string<TCHAR>, // desc
             std::basic_string<TCHAR>, // filename
             std::vector
               <
                 boost::tuple
                   <
                     std::basic_string<TCHAR>, // slotID,
                     int, // revision
                     std::basic_string<TCHAR>, // uioID
                     std::basic_string<TCHAR>, // layout
                     std::basic_string<TCHAR>, // variables
                     std::basic_string<TCHAR> // imgName
>
> // slotList
>
>, // planPageList
     std::vector
       <
         boost::tuple
           <
             std::basic_string<TCHAR>, // uuid
             int, // revision
             std::basic_string<TCHAR>, // name
             std::basic_string<TCHAR>, // desc
             std::basic_string<TCHAR>, // status
             std::basic_string<TCHAR>, // statusName,
             std::basic_string<TCHAR>, // memo
             std::basic_string<TCHAR>, // designFileName
             std::vector
               <
                 UIOVarEntry
             /*
                 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
>,
                     int,
                     float
>::type
             */
>, // varList
             std::vector< std::basic_string<TCHAR> > // wireframeList
>
> // uioList
>
     ProjectData;

Thank you,
Timothy Madden


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