]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/bimap/test/test_tagged.cpp
3 // Copyright (c) 2006-2007 Matias Capeletto
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)
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
18 #include <boost/config.hpp>
21 #include <boost/test/minimal.hpp>
23 #include <boost/static_assert.hpp>
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>
32 #include <boost/bimap/detail/test/check_metadata.hpp>
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>
46 BOOST_BIMAP_TEST_STATIC_FUNCTION( test_metafunctions
)
48 using namespace boost::bimaps::tags::support
;
49 using namespace boost::bimaps::tags
;
50 using namespace boost::mpl::placeholders
;
51 using namespace boost
;
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
));
71 using namespace boost::bimaps::tags::support
;
72 using namespace boost::bimaps::tags
;
75 typedef tagged
< data
, tag_a
> data_a
;
76 typedef tagged
< data
, tag_b
> data_b
;
78 BOOST_CHECK(( is_same
< data_a::value_type
, data
>::value
));
79 BOOST_CHECK(( is_same
< data_a::tag
, tag_a
>::value
));
82 is_same
< overwrite_tagged
< data_a
, tag_b
>::type
, data_b
>::value
85 is_same
< default_tagged
< data_a
, tag_b
>::type
, data_a
>::value
88 is_same
< default_tagged
< data
, tag_b
>::type
, data_b
>::value
91 BOOST_CHECK(( is_tagged
< data
>::value
== false ));
92 BOOST_CHECK(( is_tagged
< data_a
>::value
== true ));
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
));
99 int test_main( int, char* [] )
103 // Test metanfunctions
104 BOOST_BIMAP_CALL_TEST_STATIC_FUNCTION( test_metafunctions
);