|
Boost Users : |
From: Gottlob Frege (gottlobfrege_at_[hidden])
Date: 2007-03-23 10:52:59
On 3/23/07, Scott Meyers <usenet_at_[hidden]> wrote:
>
> // return Seq with the first occurrance of T removed
> template<typename Seq, typename T>
> struct erase_first {
> // i = Seq.find(T)
> typedef typename mpl::find<Seq, T>::type i;
>
> // found = (i == Seq.end()) ? false : true
> typedef typename mpl::if_<
> typename boost::is_same<i,
> typename mpl::end<Seq>::type
> >::type,
> mpl::false_,
> mpl::true_
> >::type found;
>
> // type = found ? Seq : Seq.erase(i)
// type = found ? Seq.erase(i) : Seq
> typedef typename mpl::if_<found,
> Seq,
> typename mpl::erase<Seq, i>::type
> >::type type;
typedef typename if_<found,
typename mpl::erase<Seq, i>::type,
Seq
>::type type;
> };
>
> BOOST_MPL_ASSERT((
> mpl::equal<
> erase_first<set1, A>::type,
> erase_first<set2, A>::type
> >
> ));
>
Or did I misunderstand?
Tony
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