
Hello, I have a use of the visitor pattern (this was an answer provided to me on c++-moderated) as shown below. Question1: is the maximum number of variant<> arguments extendable? Question2: Below, some of the variants I have are full template specs. Is there a way to write the variant<> typedef with templates instead and have the operator() of the static visitor a template member. Rds, --------------- #include <iostream> #include <boost/variant.hpp> struct derived1 {}; struct derived2 {}; struct derived3 {}; typedef boost::variant<derived1, derived2, derived3> base; // function object struct operation : boost::static_visitor<int> { int operator()(const derived1&) const { return 1; } int operator()(const derived2&) const { return 2; } int operator()(const derived3&) const { return 3; } }; int main() { base a = derived1(); operation op; std::cout << a.apply_visitor(op) << std::endl; // prints "1" base a = derived2(); std::cout << a.apply_visitor(op) << std::endl; // prints "2" }