Boost logo

Boost Users :

From: Alfred Kohl (alfred.kohl_at_[hidden])
Date: 2008-05-24 08:41:42


> struct a {};
> struct b {};
> struct c {};
>
> typedef set<a, b, c> input;
> typedef set<b, c> remove_these;
>
> struct set_inserter {
> typedef set<> state;
> typedef boost::mpl::insert<boost::mpl::_1, boost::mpl::_2> operation;
> };
>
> typedef boost::mpl::remove_if<input, boost::mpl::has_key<remove_these,
> boost::mpl::_1>, set_inserter>::type result;
>
> BOOST_MPL_ASSERT((boost::mpl::equal<result, set<a> >));

Thanks alot!
Works quite nicely.

One thing I noticed: if input and remove_these do not share at least one
common element compilation will fail (with vc8).
E.g.:

typedef set<a, b> input;
typedef set<c> remove_these;

BOOST_MPL_ASSERT((boost::mpl::equal<result, set<a, b> >));

It is not just that the assertion fails but the whole thing blows up
(multiple pages of cryptic error messages). Is that expected?
I can easily work around it by adding a dummy entry to both input and
remove_these.

Cheers,
Alfred


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