
Hi everybody, I am rather curious about how static visitation on boost::variant works and I was wondering if someone can enlighten me about this. For example, consider the following: boost::variant<long, std::string> vFoo; class my_visitor : public boost::static_visitor<> { operator()(long nValue) { ... } operator()(std::string strValue) { ... } }; vFoo = 1; //"current" type is long boost::apply_visitor(my_visitor(), vFoo); //call operator()(long nValue) vFoo = "me"; //"current" type is std::string boost::apply_visitor(my_visitor(), vFoo); //call operator()(std::string strValue) What I do not understand is, the "current" variant type seems to be changed at runtime (at assignment), then how can apply_vistor know which operator() to call at compile time? Thanks -delfin