
Hi! I am trying to create a static visitor using metapgramming. This approach worked fine in some test code, but now I face some problems. Let me first show some example: I've define an item_visitor template class: template <class Pair> //mpl::pair obtained from map sequence struct item_visitor { public: typedef typename Pair::second value_type; virtual void visit(value_type const& t) { assert(0 && "This function must be overriden in the concrete handler class!"); } }; template<class Seq> struct base_sequence_visitor : public boost::mpl::inherit_linearly < Seq , boost::mpl::inherit<boost::mpl::_1, item_visitor<boost::mpl::_2> > >::type {}; This example works fine and I can dispatch my type. Now I have some additional type, which provides a view to my structure. And I would like my visit to implemented as: virtual void visit(GenericView<Pair::second> const& t) { ... } In such a case I have to introduce a second parameter to the item_visitor template: template<class Pair, template<class> SomeView> struct item_visitor { ... }; Therefore the base_sequence_visitor must be updated as well to forward the View template: template<class Seq, template<class> SomeView> struct base_sequence_visitor : public boost::mpl::inherit_linearly < Seq , boost::mpl::inherit<boost::mpl::_1, item_visitor<boost::mpl::_2, SomeView> > >::type {}; Using this construct I get an error, that mpl::arg<2> does not have a type second. That means that the placeholder _2 does not get expanded. So I tried to "code around" and used the following trick: template<class> calss SomeView; template<class Pair> struct some_visitor : item_visitor<Pair, SomeView> {}; Then I added to the base_sequence_visitor template an additional argument, which specifies an item visitor class to be used: template<class Seq, template<class> ItemVisitor> struct base_sequence_visitor : public boost::mpl::inherit_linearly < Seq , boost::mpl::inherit<boost::mpl::_1, ItemVisitor<boost::mpl::_2> > >::type {}; And it compiles fine! But when I try to cast the base_sequence_visitor to some complete item_visitor type, which is really in the sequence I receive a compiler error, that cannot convert from 'base_sequence_visitor<Seq,ItemVisitor>' to 'ClassWhereSimpleVisitorIsDefined::simple_visitor<PairType> &' Do I miss something? With Kind Regards, Ovanes Markarian