|
Boost Users : |
From: james.jones_at_[hidden]
Date: 2005-06-16 14:55:07
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::vector<boost::recursive_variant_> >::type json_t;
Then I'd like to be able to write something like this:
class vector_assign : public boost::static_visitor<json_t&>
{
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
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