All pastes #922942 Raw Edit

mpl::unique from vector of templ

public cpp v1 · immutable
#922942 ·published 2008-02-29 03:10 UTC
rendered paste body
#include <boost/mpl/unique.hpp>#include <boost/mpl/vector.hpp>#include <boost/type_traits/is_same.hpp>#include <boost/variant.hpp>template<typename Variant>void do_something(const Variant*, int);template<typename T1, typename T2, typename T3, typename T4>void foo(const T1& arg1, const T2& arg2, const T3& arg3, const T4& arg4){    using namespace boost::mpl;    typedef vector<const int&, const int&, const char&, const float&> template_types;    /* using this instead works, but of course isn't what I want: */    /* typedef vector<const T1&, const T2&, const T3&, const T4&> template_types; */    typedef unique< template_types, boost::is_same<_1, _2> >::type            unique_template_types;    boost::make_variant_over< unique_template_types >::type args[4] = {        arg1, arg2, arg3, arg4    };    do_something(args, 4);}