Boost logo

Boost Users :

Subject: Re: [Boost-users] [MPL] Filtering a sequence to leave only most-derived types
From: Sebastian Redl (sebastian.redl_at_[hidden])
Date: 2010-02-25 07:39:02


Rutger ter Borg <rutger <at> terborg.net> writes:

>
> Not sure, but I would do something like
>
> typedef mpl::vector< A, B, C > m_vec;
>
> typedef mpl::sort<
> m_vec,
> boost::is_base_of< mpl::_1, mpl::_2 >
> >::type sorted_type;
>
> typedef mpl::unique<
> sorted_type,
> boost::is_base_of< mpl::_1, mpl::_2 >
> >::type unique_type;

Thank you, I got to the solution with this. I considered using sort+unique at
first, but dismissed it because the predicate does not define a total order, and
because is_base_of is not a proper equivalence.. But apparently it works anyway.
I just had to reverse the condition (i.e. define a is_derived_from metafunction).

Sebastian


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net