Is it possible to change a variant's type within a visitor function? What I'd like to do is something like this:
typedef boost::make_recursive_variant<
int,
std::string,
std::vectorboost::recursive_variant_ >::type json_t;
Then I'd like to be able to write something like this:
class vector_assign : public boost::static_visitor
{
public:
vector_assign(int key, const json_t& value);
json_t& operator()(int&);
json_t& operator()(std::string&);
json_t& operator()(vector_t&);
private:
int key;
json_t& value;
};
json_t&
vector_assign::operator(vector_t& v)
{
// the canonical case - we assign a value to a slot in the vector
if(key>=v.size())
v.reserve(key);
v[key] = value;
return v;
}
json_t&
map_assign::operator(int& i)
{
// here we want to discard the int value and convert the variant into a new vector with a single value - but how?
}
Thanks,
-
James Jones Administrative Data Mgmt.
(v)732-510-1806 375 Raritan Center Pkwy, Suite A
(f)732-510-1855 Edison, NJ 08837