[mpl] remove duplicates in (non-integral) type sequences
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
::type without_duplicates;
BOOST_MPL_ASSERT_RELATION(size
Karl Friedrich Walkow
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...
// untested template <class S> remove_duplicates { typedef typename fold< S , pair< typename clear<S>::type, set0<> > , if_< contains< second<_1>, _2 > , _1 , pair< push_back< first<_1>, _2> , insert< second<_1>, _2 > > > >::type::first type; }; HTH, -- Dave Abrahams Boost Consulting www.boost-consulting.com
Great, it works, thank you. According to the reference manual, the contains function works on every forward sequence, but that's not right... regards, karl
participants (2)
-
David Abrahams
-
Karl Friedrich Walkow