2016-04-14 13:06 GMT+02:00 Peter Dimov
Andrzej Krzemienski wrote:
The problem I am solving is to how to access the whole variant object from inside a static visitor:
``` using VariantOb = boost::variant<Ob>;
struct MyVisitor : boost::static_visitor<> { void operator()(Ob const& ob) const
Can't you have
struct MyVisitor { typedef void result_type; void operator()(Ob const& ob, Var const& var) const; };
and then pass bind( MyVisitor(), _1, ref(v) ) to visit?
I suppose, I can. In fact, currently my visitor looks like this: ``` struct MyVisitor : boost::static_visitor<> { VariantOb const& v_; MyVisitor(VariantOb const& v) : v_(v) {} void operator()(Ob const& ob) const { boost::addressof(v_); } }; ``` But, I am trying to optimize a function that I believe is slower than ideal, and my hypothesis is that this carrying of the additional pointer around is the culprit. In order to confirm it, I need to be able to get the address of the containing variant object in flight and compare this to the current solution. Regards, &rzej