c++ - Boost variant and visitor -


i have 2 structures base , derived , boost:variant 2 types.

struct base : public boost::static_visitor<> {     virtual void operator(type1& t) {}     virtual void operator(type2& t) {} }; 

what want do define derived as:

struct derived : public base {     void operator(type1& t) { /*some impl*/ } }; 

i not override operator type2 assuming defined in base , empty.

for reason if write

derived visitor; boost::apply_visitor(visitor, variant); 

i error: no match call '(derived) (type2&)'

of course, if add operator type2 derived works ok.
please understand why not working without adding operator type2?

name lookup doesn't consider operators in base classes. need explicitly bring in derived's scope seen name lookup:

struct derived : public base {     void operator()(type1& t) { /*some impl*/ }     using base::operator(); }; 

Comments