Boost logo

Boost Users :

From: Scott Meyers (usenet_at_[hidden])
Date: 2007-03-17 01:38:10


David Abrahams wrote:
> template <class OuterSequence, InnerSequence>
> struct includes
> : boost::is_same<
> typename mpl::find_if<
> InnerSequence
> , mpl::not_<
> mpl::contains<OuterSequence, _1>
> >
> >::type
> , typename mpl::end<SubSequence>::type
> >
> {};

Okay, thanks very much. This works for me, and I even pretty much
understand it :-).

Unfortunately, I can't make the leap from this to what I really want,
which is to provide a predicate to contains for determining whether two
types are the same.

I think I need to do something like this, and I apologize in advance for
what will probably strike you as appalling:

// returns whether Seq1 includes each of the elements in Seq2.
// Pred defines whether 2 types are the same.
template<typename Seq1, // the putative superset
          typename Seq2, // the putative subset
          typename Pred> // whether T1 from Seq1 == T2 from Seq2
struct includes_if
: boost::is_same<
     typename find_if<
       Seq2,
       not_<
         is_same<
           find_if<Seq1,
                   Pred::apply<_1 from outer find_if,
                               _1 from inner find_if>
>
           typename end<Seq1>::type
>
>::type,
     typename end<Seq2>::type
>
{};

I don't know how to refer to the current elements of the two calls to
find_if, and I don't know whether it's a syntax issue or if I'm just
approaching this incorrectly.

Help?

Thanks,

Scott


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