On 07/08/10 02:11, Timothy Madden wrote:
Larry Evans wrote: [snip]
Maybe you could just use pointers to the enclosing composite, like in:
#include
#include <vector> struct tuple_tree : std::tr1::tuple < float , int , std::vector
{ };
I can use vector
directly, with no pointer needed, and it works,
Hmm... I'm surprised. I would have thought a pointer would be needed to break the recursion because, otherwise, the tuple_tree CTOR would create an infinite tree. But now that I think more about it, the pointer is within the std::vector. No infinite tree is created because the vector is initially empty.
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
What happens if you just use this, IOW, just std::vector<UIOVarEntry>. There'd be no infinite tree created for the reasons cited earlier. Wouldn't this satisfy your requirements?
/* 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::vectorboost::recursive_variant_ // childList >, int, float >::type */ >, // varList std::vector< std::basic_string<TCHAR> > // wireframeList > > // uioList
ProjectData;
Thank you, Timothy Madden