Boost logo

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<
    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&>
    vector_assign(int key, const json_t& value);
    json_t& operator()(int&);
    json_t& operator()(std::string&);
    json_t& operator()(vector_t&);
    int key;
    json_t& value;

vector_assign::operator(vector_t& v)
    // the canonical case - we assign a value to a slot in the vector
    v[key] = value;
    return v;

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?

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, kalb at, bjorn.karlsson at, gregod at, wekempf at