1 | /* Boost.MultiIndex test for MPL operations. |
2 | * |
3 | * Copyright 2003-2008 Joaquin M Lopez Munoz. |
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/multi_index for library home page. |
9 | */ |
10 | |
11 | #include "test_mpl_ops.hpp" |
12 | |
13 | #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */ |
14 | #include "pre_multi_index.hpp" |
15 | #include <boost/multi_index_container.hpp> |
16 | #include <boost/multi_index/identity.hpp> |
17 | #include <boost/multi_index/ordered_index.hpp> |
18 | #include <boost/multi_index/sequenced_index.hpp> |
19 | #include <boost/mpl/at.hpp> |
20 | #include <boost/mpl/list.hpp> |
21 | |
22 | using namespace boost::multi_index; |
23 | |
24 | void test_mpl_ops() |
25 | { |
26 | typedef multi_index_container< |
27 | int, |
28 | indexed_by< |
29 | ordered_unique<identity<int> >, |
30 | ordered_non_unique<identity<int> > |
31 | > |
32 | > indexed_t1; |
33 | |
34 | BOOST_STATIC_ASSERT((boost::is_same< |
35 | boost::mpl::at_c<indexed_t1::index_specifier_type_list,0>::type, |
36 | ordered_unique<identity<int> > >::value)); |
37 | BOOST_STATIC_ASSERT((boost::is_same< |
38 | boost::mpl::at_c<indexed_t1::index_specifier_type_list,1>::type, |
39 | ordered_non_unique<identity<int> > >::value)); |
40 | |
41 | typedef boost::mpl::push_front< |
42 | indexed_t1::index_specifier_type_list, |
43 | sequenced<> |
44 | >::type index_list_t; |
45 | |
46 | typedef multi_index_container< |
47 | int, |
48 | index_list_t |
49 | > indexed_t2; |
50 | |
51 | BOOST_STATIC_ASSERT((boost::is_same< |
52 | boost::mpl::at_c<indexed_t2::index_specifier_type_list,0>::type, |
53 | sequenced<> >::value)); |
54 | BOOST_STATIC_ASSERT((boost::is_same< |
55 | boost::mpl::at_c<indexed_t2::index_specifier_type_list,1>::type, |
56 | boost::mpl::at_c<indexed_t1::index_specifier_type_list,0>::type>::value)); |
57 | BOOST_STATIC_ASSERT((boost::is_same< |
58 | boost::mpl::at_c<indexed_t2::index_specifier_type_list,2>::type, |
59 | boost::mpl::at_c<indexed_t1::index_specifier_type_list,1>::type>::value)); |
60 | |
61 | typedef multi_index_container< |
62 | int, |
63 | boost::mpl::list< |
64 | ordered_unique<identity<int> >, |
65 | ordered_non_unique<identity<int> > |
66 | > |
67 | > indexed_t3; |
68 | |
69 | BOOST_STATIC_ASSERT((boost::is_same< |
70 | boost::mpl::at_c<indexed_t3::index_specifier_type_list,0>::type, |
71 | boost::mpl::at_c<indexed_t1::index_specifier_type_list,0>::type>::value)); |
72 | BOOST_STATIC_ASSERT((boost::is_same< |
73 | boost::mpl::at_c<indexed_t3::index_specifier_type_list,1>::type, |
74 | boost::mpl::at_c<indexed_t1::index_specifier_type_list,1>::type>::value)); |
75 | } |
76 | |