|
Boost Users : |
Subject: [Boost-users] [MPL] unique not working?
From: Michael Marcin (mike.marcin_at_[hidden])
Date: 2013-10-13 23:44:22
I pass a mpl::vector with duplicates to mpl::unique and the result still
has duplicates.
What am I doing wrong?
http://coliru.stacked-crooked.com/a/fe85b5739eb4c15f
#include <boost/mpl/vector.hpp>
#include <boost/mpl/unique.hpp>
#include <boost/mpl/equal_to.hpp>
#include <boost/mpl/placeholders.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/mpl/print.hpp>
template< typename... Args >
void test( const Args&... args )
{
using namespace boost::mpl;
using namespace boost::mpl::placeholders;
typedef vector<Args...> args_types;
typedef typename unique<args_types,
boost::is_same<_1, _2> >::type unique_types;
print< unique_types > x;
}
int main()
{
int a = 0;
char b = 0;
test( a, b, a );
}
+ g++-4.8 -std=c++11 -O2 -Wall -pedantic -pthread main.cpp
main.cpp: In instantiation of void test(const Args& ...) [with Args =
{int, char, int}]:
main.cpp:22:19: required from here
main.cpp:15:27: warning: unused variable x [-Wunused-variable]
print< unique_types > x;
^
+ ./a.out
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