Boost logo

Boost Users :

From: David Abrahams (dave_at_[hidden])
Date: 2005-12-12 16:38:41


Karl Friedrich Walkow <walkow_at_[hidden]> writes:

> 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

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