Boost logo

Boost Users :

Subject: [Boost-users] help with boost::variant, accessing recursive types
From: Littlefield, Tyler (tyler_at_[hidden])
Date: 2016-09-29 01:08:20


all,
I have the following:
boost::make_recursive_variant<int, bool, std::string,
std::map<std::string, boost::recursive_variant_>>::type node;
I'm populating this tree. I'm using libucl because it has a relaxed JSON
syntax but I wanted to have a tree-like configuration here. The std::map
is a key:value pair obviously. So my questions:
How do I get std::maps from this variant? I know boost::get exists, will
it just return a pointer to std::map? does setting elements in the map
set elements on the variant?
I also didn't see any return info for what boost::get returns if the
element does not exist. Will it just return null since it does return a T*?
Finally, is there a way to see the type of the variant? I don't really
care if it's a bool or string, although I would like to place some
implicit checks on certain values when they're retrieved.

PS: If there's a way to pull this off with boost::property_tree, I would
love to know how. I'm looking at using libucl as mentioned before
because it provides a nginx-like not really JSON-style configuration syntax.

Any tips would be appreciated. HOpefully these questions are clear and
make sense.

-- 
Take care,
Ty
Twitter: @sorressean
Web: https://tysdomain.com
Pubkey: https://tysdomain.com/files/pubkey.asc

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