]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/bimap/test/test_tagged.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / bimap / test / test_tagged.cpp
1 // Boost.Bimap
2 //
3 // Copyright (c) 2006-2007 Matias Capeletto
4 //
5 // Distributed under the Boost Software License, Version 1.0.
6 // (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
8
9 // VC++ 8.0 warns on usage of certain Standard Library and API functions that
10 // can be cause buffer overruns or other possible security issues if misused.
11 // See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx
12 // But the wording of the warning is misleading and unsettling, there are no
13 // portable alternative functions, and VC++ 8.0's own libraries use the
14 // functions in question. So turn off the warnings.
15 #define _CRT_SECURE_NO_DEPRECATE
16 #define _SCL_SECURE_NO_DEPRECATE
17
18 #include <boost/config.hpp>
19
20 // Boost.Test
21 #include <boost/test/minimal.hpp>
22
23 #include <boost/static_assert.hpp>
24
25 // Boost.MPL
26 #include <boost/type_traits/is_same.hpp>
27 #include <boost/mpl/placeholders.hpp>
28 #include <boost/mpl/assert.hpp>
29 #include <boost/type_traits/add_const.hpp>
30
31 // Boost.Bimap
32 #include <boost/bimap/detail/test/check_metadata.hpp>
33
34 // Boost.Bimap.Tags
35 #include <boost/bimap/tags/tagged.hpp>
36 #include <boost/bimap/tags/support/default_tagged.hpp>
37 #include <boost/bimap/tags/support/is_tagged.hpp>
38 #include <boost/bimap/tags/support/overwrite_tagged.hpp>
39 #include <boost/bimap/tags/support/tag_of.hpp>
40 #include <boost/bimap/tags/support/value_type_of.hpp>
41 #include <boost/bimap/tags/support/apply_to_value_type.hpp>
42
43
44
45
46 BOOST_BIMAP_TEST_STATIC_FUNCTION( test_metafunctions )
47 {
48 using namespace boost::bimaps::tags::support;
49 using namespace boost::bimaps::tags;
50 using namespace boost::mpl::placeholders;
51 using namespace boost;
52
53 struct tag {};
54 struct value {};
55
56 // Test apply_to_value_type metafunction
57 // tagged<value,tag> ----(add_const<_>)----> tagged<value const,tag>
58 typedef tagged< value, tag > ttype;
59 typedef apply_to_value_type< add_const<_>,ttype>::type result;
60 typedef is_same<tagged<value const,tag>,result> compare;
61 BOOST_MPL_ASSERT_MSG(compare::value,tag,(result));
62 }
63
64 struct tag_a {};
65 struct tag_b {};
66 struct data {};
67
68 void test_function()
69 {
70
71 using namespace boost::bimaps::tags::support;
72 using namespace boost::bimaps::tags;
73 using boost::is_same;
74
75 typedef tagged< data, tag_a > data_a;
76 typedef tagged< data, tag_b > data_b;
77
78 BOOST_CHECK(( is_same< data_a::value_type , data >::value ));
79 BOOST_CHECK(( is_same< data_a::tag , tag_a >::value ));
80
81 BOOST_CHECK((
82 is_same< overwrite_tagged < data_a, tag_b >::type, data_b >::value
83 ));
84 BOOST_CHECK((
85 is_same< default_tagged < data_a, tag_b >::type, data_a >::value
86 ));
87 BOOST_CHECK((
88 is_same< default_tagged < data , tag_b >::type, data_b >::value
89 ));
90
91 BOOST_CHECK(( is_tagged< data >::value == false ));
92 BOOST_CHECK(( is_tagged< data_a >::value == true ));
93
94 BOOST_CHECK(( is_same< value_type_of<data_a>::type, data >::value ));
95 BOOST_CHECK(( is_same< tag_of <data_a>::type, tag_a >::value ));
96
97 }
98
99 int test_main( int, char* [] )
100 {
101 test_function();
102
103 // Test metanfunctions
104 BOOST_BIMAP_CALL_TEST_STATIC_FUNCTION( test_metafunctions );
105
106 return 0;
107 }
108