1 | |
2 | // Copyright Aleksey Gurtovoy 2001-2004 |
3 | // |
4 | // Distributed under the Boost Software License, Version 1.0. |
5 | // (See accompanying file LICENSE_1_0.txt or copy at |
6 | // http://www.boost.org/LICENSE_1_0.txt) |
7 | // |
8 | // See http://www.boost.org/libs/mpl for documentation. |
9 | |
10 | // $Id$ |
11 | // $Date$ |
12 | // $Revision$ |
13 | |
14 | #include <boost/mpl/insert_range.hpp> |
15 | #include <boost/mpl/find.hpp> |
16 | #include <boost/mpl/vector_c.hpp> |
17 | #include <boost/mpl/list.hpp> |
18 | #include <boost/mpl/set.hpp> |
19 | #include <boost/mpl/set_c.hpp> |
20 | #include <boost/mpl/map.hpp> |
21 | #include <boost/mpl/size.hpp> |
22 | #include <boost/mpl/range_c.hpp> |
23 | #include <boost/mpl/equal.hpp> |
24 | #include <boost/mpl/fold.hpp> |
25 | #include <boost/mpl/placeholders.hpp> |
26 | #include <boost/mpl/logical.hpp> |
27 | #include <boost/mpl/contains.hpp> |
28 | #include <boost/mpl/joint_view.hpp> |
29 | |
30 | #include <boost/mpl/aux_/test.hpp> |
31 | |
32 | MPL_TEST_CASE() |
33 | { |
34 | typedef vector_c<int,0,1,7,8,9> numbers; |
35 | typedef find< numbers,integral_c<int,7> >::type pos; |
36 | typedef insert_range< numbers,pos,range_c<int,2,7> >::type range; |
37 | |
38 | MPL_ASSERT_RELATION( size<range>::value, ==, 10 ); |
39 | MPL_ASSERT(( equal< range,range_c<int,0,10> > )); |
40 | |
41 | typedef insert_range< list0<>,end< list0<> >::type,list1<int> >::type result2; |
42 | MPL_ASSERT_RELATION( size<result2>::value, ==, 1 ); |
43 | } |
44 | |
45 | template<typename A, typename B> |
46 | void test_associative() |
47 | { |
48 | typedef typename insert_range< A,typename end< A >::type,B >::type C; |
49 | |
50 | MPL_ASSERT_RELATION( size<C>::value, <=, (size<A>::value + size<B>::value) ); |
51 | MPL_ASSERT(( fold< joint_view< A,B >,true_,and_< _1,contains< C,_2 > > > )); |
52 | } |
53 | |
54 | MPL_TEST_CASE() |
55 | { |
56 | typedef set3< short,int,long > signed_integers; |
57 | typedef set3< unsigned short,unsigned int,unsigned long > unsigned_integers; |
58 | test_associative<signed_integers, unsigned_integers>(); |
59 | |
60 | typedef set_c< int,1,3,5,7,9 > odds; |
61 | typedef set_c< int,0,2,4,6,8 > evens; |
62 | test_associative<odds, evens>(); |
63 | |
64 | typedef map2< |
65 | pair< void,void* > |
66 | , pair< int,int* > |
67 | > pointers; |
68 | typedef map2< |
69 | pair< void const,void const* > |
70 | , pair< int const,int const* > |
71 | > pointers_to_const; |
72 | test_associative<pointers, pointers_to_const>(); |
73 | } |
74 | |