[Variant] Tree like structure with variant

Hi all, I need a tree-like structure like the following boost::variant< int, std::vector<tree>, std::map<std::string, tree> > tree; So, my tree can have an int, or a list of trees, or a map of trees. Of course this is not possible, and I've been trying to use boost::recursive_wrapper. I have looked at the example in the documentation, but and I'm not able to achieve what I want. My feeling is that I'm missing an extra 'node' level somewhere, but since all the types I'm using are typedefs, I cannot forward delcare it to break the cyclic reference... I would appreciate help with this. Thanks in advance.

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Might I interest you in some Prana? http://github.com/brycelelbach/prana http://thread.gmane.org/gmane.comp.parsers.spirit.general/20853 Not done yet, but it should be in a usable state soon. On Thu, 21 Oct 2010 10:39:50 +0200 dariomt@gmail.com wrote:
Hi all,
I need a tree-like structure like the following
boost::variant< int, std::vector<tree>, std::map<std::string, tree> > tree;
So, my tree can have an int, or a list of trees, or a map of trees.
Of course this is not possible, and I've been trying to use boost::recursive_wrapper. I have looked at the example in the documentation, but and I'm not able to achieve what I want. My feeling is that I'm missing an extra 'node' level somewhere, but since all the types I'm using are typedefs, I cannot forward delcare it to break the cyclic reference...
I would appreciate help with this. Thanks in advance.
- -- Bryce Lelbach aka wash http://groups.google.com/group/ariel_devel -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAkzAE5cACgkQO/fqqIuE2t6/2ACgk1Aw/TnQjWcIgolfRDVZ1KXQ 5kYAoOrsWDAtRt99gihClUgz9T/A31hm =99z5 -----END PGP SIGNATURE-----

On 21/10/10 09:39, dariomt@gmail.com wrote:
Hi all,
I need a tree-like structure like the following
boost::variant< int, std::vector<tree>, std::map<std::string, tree> > tree;
boost::make_recursive_variant< int, std::vector< boost::recursive_variant_ >, std::map< std::string, boost::recursive_variant_ >
::type tree;

Mathias Gaunard <mathias.gaunard <at> ens-lyon.org> writes:
On 21/10/10 09:39, dariomt <at> gmail.com wrote:
Hi all,
I need a tree-like structure like the following
boost::variant< int, std::vector<tree>, std::map<std::string, tree> > tree;
boost::make_recursive_variant< int, std::vector< boost::recursive_variant_ >, std::map< std::string, boost::recursive_variant_ >
::type tree;
*blush* It was right there, if I only had read the docs to the end... Thanks a lot!
participants (4)
-
Bryce Lelbach
-
dariomt
-
dariomt@gmail.com
-
Mathias Gaunard