1 | #include <boost/mpl/vector_c.hpp>
|
---|
2 | #include <boost/mpl/not.hpp>
|
---|
3 | #include <boost/mpl/fold.hpp>
|
---|
4 | #include <boost/mpl/vector.hpp>
|
---|
5 | #include <boost/mpl/copy_if.hpp>
|
---|
6 | #include <boost/mpl/contains.hpp>
|
---|
7 | #include <boost/mpl/for_each.hpp>
|
---|
8 | #include <boost/mpl/transform.hpp>
|
---|
9 | #include <boost/type_traits/is_same.hpp>
|
---|
10 | #include <iostream>
|
---|
11 |
|
---|
12 | typedef boost::mpl::vector_c<int,1,2,3,4,5,6,7,8,9,10>::type left;
|
---|
13 | typedef boost::mpl::vector_c<int,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70
|
---|
14 | #if 1
|
---|
15 | ,71
|
---|
16 | #endif
|
---|
17 | >::type right;
|
---|
18 |
|
---|
19 | struct join_unique
|
---|
20 | {
|
---|
21 | template <class Sequence1,
|
---|
22 | class Sequence2>
|
---|
23 | struct apply
|
---|
24 | {
|
---|
25 | typedef typename boost::mpl::copy_if<
|
---|
26 | Sequence2,
|
---|
27 | boost::mpl::not_<
|
---|
28 | boost::mpl::contains<
|
---|
29 | Sequence1,
|
---|
30 | boost::mpl::placeholders::_1> >,
|
---|
31 | boost::mpl::back_inserter<Sequence1>
|
---|
32 | >::type type;
|
---|
33 | };
|
---|
34 | };
|
---|
35 |
|
---|
36 | typedef typename join_unique::apply<left,right>::type joined;
|
---|
37 |
|
---|
38 | struct printer {
|
---|
39 | template <typename T>
|
---|
40 | void operator()(const T& val)
|
---|
41 | {
|
---|
42 | std::cout << val << std::endl;
|
---|
43 | }
|
---|
44 | };
|
---|
45 |
|
---|
46 | int main() {
|
---|
47 | boost::mpl::for_each<joined>(printer());
|
---|
48 | }
|
---|
49 |
|
---|