
Hi, I've got an MPL sequence containing a (rather small) number of classes. I want to filter this sequence so that all classes that are a base of another class in the sequence are filtered out. I thought I'd do something like this (in pseudo-code): is_strict_base_of(Base, Derived) = !is_same(Base, Derived) && is_base_of(Base, Derived) Result = remove_if( Interfaces, find_if( Interfaces, is_strict_base_of(outer_value, inner_value) ) != end(Interfaces) ) where outer_value is the iteration value of the remove_if loop, and inner_value is the iteration value of the count_if loop. Yes, this is N², but since the length of the initial sequence is very unlikely to exceed 8, I can live with that. In MPL syntax: template <typename Base, typename Derived> struct is_strict_base_of : mpl::and_< mpl::not_<boost::is_same<Base, Derived> >, boost::is_base_of<Base, Derived> > {}; typedef typename mpl::remove_if< Interfaces, // Remove from Interfaces mpl::not_<mpl::equal< mpl::find_if< Interfaces, // if there is any value in interfaces // that this is a base of is_strict_base_of<???> >, mpl::end<Interfaces> > >
::type Bases;
How do I represent outer_value and inner_value in this expression? It seems I can't simply put mpl::_1 and mpl::_2 there, since that gives me a static assertion failure (argument is not available). I think I have to put an apply somewhere in there, but I can't figure out where. Sebastian