I have a static visitor setup like this
struct visitor : public boost::static_visitor<std::string&> {
obj& m_data;
visitor(obj& data) : m_data(data) {}
std::string& operator()(key_type_1& k1) const {
return m_data.get(k1);
}
std::string& operator()(key_type_2& k2) const {
return m_data.get(k2);
}
}
There are no compilation errors and everything looks good initially. But, this test case fails -
std::string x = boost::apply_visitor(visitor(data1), variant);
std::string y = boost::apply_visitor(visitor(data2), variant);
the second call is still trying to retrieve from data1. Am i doing something wrong here?