On 9/29/2016 1:08 AM, Littlefield, Tyler wrote:
all, I have the following: boost::make_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:
I am not an expert with variant, but give answers from reading the docs.
How do I get std::maps from this variant?
typedef boost::make_recursive_variant
I know boost::get exists, will it just return a pointer to std::map?
Yes, if you pass it a pointer to your variant.
does setting elements in the map set elements on the variant?
If you get a pointer or a reference to your map in the variant any changes you make to the map is changing what is in 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*?
Yes if you get a pointer. If you try to get a reference and it does not exist it throws a bad_get exception.
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.
This I do not know.
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.