Recursive variant problem
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::vectorboost::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
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::vectorboost::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
{
};
int main(void)
{
tuple_tree tt;
std::vector
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::vectorboost::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
#include <vector> struct tuple_tree : std::tr1::tuple < float , int , std::vector
{ };
I can use vector
{ }; 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::vectorboost::recursive_variant_ // childList >, int, float >::type */ >, // varList std::vector< std::basic_string<TCHAR> > // wireframeList > > // uioList
ProjectData; Thank you, Timothy Madden
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
Larry Evans wrote:
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.
Well, as you can see, some people say you were correct, after all, because C++ might place a requirement to always use complete types for containers.
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:
[...]
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? [...]
It bothers me that to compose my large structure I need some previously declared class UIOVarEntry, to hold a certain number of components from my big typedef. With make_recursive_variant I could have all my structure declared in-place at once. Thank you, Timothy Madden
On 07/08/10 09:09, Mathias Gaunard wrote:
On 08/07/10 08:11, Timothy Madden wrote:
struct tuple_tree : std::tr1::tuple < float , int , std::vector
{ };
I can use vector
directly This is not allowed by the C++ standard. Types must be complete.
The attached compiles/runs OK with gcc4.4 and gcc4.5. Are they wrong? I initially thought like you, but after the attached compiled and ran, I'm not so sure.
Mathias Gaunard wrote:
On 08/07/10 08:11, Timothy Madden wrote:
struct tuple_tree : std::tr1::tuple < float , int , std::vector
{ };
I can use vector
directly This is not allowed by the C++ standard. Types must be complete.
I do not see this requirement in the standard. Where should I look for it ? Thank you, Timothy Madden
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::vectorboost::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
So what am I missing ? Why is boost::recursive_variant_ not being substituted ? Timothy Madden
AMDG Timothy Madden wrote:
Timothy Madden wrote:
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 > >::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.
So what am I missing ? Why is boost::recursive_variant_ not being substituted ?
My guess would be that tuple has more template arguments than make_recursive_variant is designed to handle. In Christ, Steven Watanabe
participants (4)
-
Larry Evans
-
Mathias Gaunard
-
Steven Watanabe
-
Timothy Madden