
i try to find a solution for eliminating all duplicates of types in a non-integral sequence. the only extisting solution i found has a set< > as output, but i want to keep the sequence type. the following code _should_ solve the problem, but there seems to be something wrong with it. if someone has an idea... #include <boost/mpl/assert.hpp> #include <boost/mpl/vector.hpp> #include <boost/mpl/fold.hpp> #include <boost/mpl/empty_sequence.hpp> #include <boost/mpl/contains.hpp> #include <boost/mpl/if.hpp> #include <boost/mpl/joint_view.hpp> #include <boost/mpl/single_view.hpp> #include <boost/mpl/size.hpp> using namespace boost::mpl; struct E {}; struct F {}; struct G {}; struct H {}; int main(int argc, char* argv[]) { typedef vector< E, E, F, E, G, H, G, G, F, G >::type with_duplicates; typedef fold< with_duplicates, empty_sequence, if_< contains< _1, _2 >::type, _1, joint_view< _1, single_view< _2 >::type >::type >::type
::type without_duplicates;
BOOST_MPL_ASSERT_RELATION(size<with_duplicates>::value, ==, 10); BOOST_MPL_ASSERT_RELATION(size<without_duplicates>::value, ==, 4); return 0; } much thanks in advance, karl