]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/type_erasure/test/test_reference.cpp
1 // Boost.TypeErasure library
3 // Copyright 2011 Steven Watanabe
5 // Distributed under the Boost Software License Version 1.0. (See
6 // accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
11 #include <boost/type_erasure/any.hpp>
12 #include <boost/type_erasure/tuple.hpp>
13 #include <boost/type_erasure/builtin.hpp>
14 #include <boost/type_erasure/operators.hpp>
15 #include <boost/type_erasure/any_cast.hpp>
16 #include <boost/mpl/vector.hpp>
18 #define BOOST_TEST_MAIN
19 #include <boost/test/unit_test.hpp>
21 using namespace boost::type_erasure
;
29 class with_destroy
: public no_destroy
35 template<class T
= _self
>
36 struct common
: ::boost::mpl::vector
<
38 copy_constructible
<T
>,
42 BOOST_AUTO_TEST_CASE(test_basic
)
44 typedef ::boost::mpl::vector
<typeid_
<> > test_concept
;
46 any
<test_concept
, _self
&> x(static_cast<no_destroy
&>(val
));
47 no_destroy
& ref
= any_cast
<no_destroy
&>(x
);
48 BOOST_CHECK_EQUAL(&ref
, &val
);
51 BOOST_AUTO_TEST_CASE(test_increment
)
53 typedef ::boost::mpl::vector
<incrementable
<> > test_concept
;
55 any
<test_concept
, _self
&> x(i
);
57 BOOST_CHECK_EQUAL(i
, 1);
60 BOOST_AUTO_TEST_CASE(test_add
)
62 typedef ::boost::mpl::vector
<common
<>, addable
<> > test_concept
;
65 any
<test_concept
, _self
&> x(i
);
66 any
<test_concept
, _self
&> y(j
);
67 any
<test_concept
, _self
> z(x
+ y
);
68 int k
= any_cast
<int>(z
);
69 BOOST_CHECK_EQUAL(k
, 3);
72 BOOST_AUTO_TEST_CASE(test_mixed_add
)
74 typedef ::boost::mpl::vector
<common
<>, addable
<> > test_concept
;
77 any
<test_concept
, _self
&> x(i
);
78 any
<test_concept
, _self
> y(j
);
79 any
<test_concept
, _self
> z(x
+ y
);
80 int k
= any_cast
<int>(z
);
81 BOOST_CHECK_EQUAL(k
, 3);