[mpl] A partioning unique/non-unique algorithm

Greetings, How would you combine the boost::mpl::partition and boost::mpl::unique algorithms such that an element that is not placed into the first inserter (for unique elements) is placed into the second inserter (for non-unique elements)? Thanks, Eric.

Eric Lemings writes:
How would you combine the boost::mpl::partition and boost::mpl::unique algorithms such that an element that is not placed into the first inserter (for unique elements) is placed into the second inserter (for non-unique elements)?
I'm afraid you can't combine them literally, but you can use the "Semantics" section from the algorithms' reference pages to get an idea of how to approach this, e.g. (untested!): template< typename Seq , typename Pred , typename In1 , typename In2 > struct unique_partition : fold< iterator_range< typename next< typename begin<Seq>::type >::type , typename end<Seq>::type > , vector3< typename In1::state , typename In2::state , typename front<Seq>::type > , if_< apply2< Pred, at<_1,int_<2> >, _2 > , vector3< apply2< typename In1::operation, at<_1,int_<0> >, _2 > , at<_1,int_<1> > , _2 > , vector3< at<_1,int_<0> , apply2< typename In2::operation, at<_1,int_<1> >, _2 > , _2 > > > { }; HTH, -- Aleksey Gurtovoy MetaCommunications Engineering
participants (2)
-
Aleksey Gurtovoy
-
Eric Lemings