Boost logo

Boost :

Subject: Re: [boost] [variant] awkward recursion
From: Balazs Arva (arvabalazs_at_[hidden])
Date: 2012-10-29 19:30:20


At this moment I'm developing a json library with similar approach.
With variant I think the only way this:
typedef boost::make_recursive_variant
 <
int,
unsigned int,
long,
unsigned long,
float,
double,
bool,
const char*,
std::string,
boost::recursive_wrapper<std::map<std::string, boost::recursive_variant_>>,
std::vector<boost::recursive_variant_>,
std::nullptr_t
>::type value;

typedef std::vector<value> array;
typedef std::map<std::string, value> object;

I did not find any better solution.
However there is still one problem:
I do not want to write down every numeric POD in tmpl parameter list. It is
a major problem because
value a=(unsigned int)5;
could not compile.
Do you have any advice? I would like do something like this:

typedef boost::make_recursive_variant
  <
any_pod_numeric_type,
bool,
const char*,
std::string,
boost::recursive_wrapper<std::map<std::string, boost::recursive_variant_>>,
std::vector<boost::recursive_variant_>,
std::nullptr_t
>::type value;

Balazs Arva


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk