]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/type_erasure/test/test_deduced.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / type_erasure / test / test_deduced.cpp
1 // Boost.TypeErasure library
2 //
3 // Copyright 2011 Steven Watanabe
4 //
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)
8 //
9 // $Id$
10
11 #include <boost/type_erasure/any.hpp>
12 #include <boost/type_erasure/builtin.hpp>
13 #include <boost/type_erasure/operators.hpp>
14 #include <boost/type_erasure/any_cast.hpp>
15 #include <boost/type_erasure/deduced.hpp>
16 #include <boost/mpl/vector.hpp>
17 #include <boost/mpl/assert.hpp>
18 #include <boost/type_traits/remove_pointer.hpp>
19 #include <boost/type_traits/is_same.hpp>
20
21 #define BOOST_TEST_MAIN
22 #include <boost/test/unit_test.hpp>
23
24 using namespace boost::type_erasure;
25
26 template<class T = _self>
27 struct common : ::boost::mpl::vector<
28 copy_constructible<T>,
29 typeid_<T>
30 > {};
31
32 BOOST_AUTO_TEST_CASE(test_deduce_dereference)
33 {
34 typedef ::boost::mpl::vector<
35 copy_constructible<>,
36 typeid_<deduced<boost::remove_pointer<_self> >::type>,
37 dereferenceable<deduced<boost::remove_pointer<_self> >&>
38 > test_concept;
39 int i;
40 any<test_concept> x(&i);
41 any<test_concept, deduced<boost::remove_pointer<_self> >&> y(*x);
42 BOOST_CHECK_EQUAL(&any_cast<int&>(y), &i);
43 }
44
45 BOOST_MPL_ASSERT((
46 boost::is_same<
47 deduced<boost::remove_pointer<_self> >::type,
48 deduced<boost::remove_pointer<_self> > >));
49
50 BOOST_MPL_ASSERT((
51 boost::is_same<deduced<boost::remove_pointer<int*> >::type, int >));