]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/type_traits/test/common_type_5_test.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / type_traits / test / common_type_5_test.cpp
1
2 // Copyright Peter Dimov 2015
3 // Use, modification and distribution are subject to the
4 // Boost Software License, Version 1.0. (See accompanying file
5 // LICENSE_1_0.txt or copy at http://www.tt.org/LICENSE_1_0.txt)
6
7 #include "test.hpp"
8 #include "check_type.hpp"
9 #ifdef TEST_STD
10 # include <type_traits>
11 #else
12 # include <boost/type_traits/common_type.hpp>
13 #endif
14 #include <iostream>
15
16 template<class T> struct X
17 {
18 T t_;
19
20 X(): t_() {}
21 template<class U> X( X<U> const & x ): t_( x.t_ ) {}
22 };
23
24 namespace boost
25 {
26
27 template<class T, class U> struct common_type< X<T>, X<U> >
28 {
29 typedef X<typename common_type<T, U>::type> type;
30 };
31
32 } // namespace boost
33
34 TT_TEST_BEGIN(common_type_5)
35 {
36 // user specializations, binary
37
38 BOOST_CHECK_TYPE3( tt::common_type< X<char>, X<char> >::type, X<char> );
39
40 BOOST_CHECK_TYPE3( tt::common_type< X<char>&, X<char>& >::type, X<char> );
41 BOOST_CHECK_TYPE3( tt::common_type< X<char>&, X<char> const& >::type, X<char> );
42 BOOST_CHECK_TYPE3( tt::common_type< X<char> const&, X<char>& >::type, X<char> );
43 BOOST_CHECK_TYPE3( tt::common_type< X<char> const&, X<char> const& >::type, X<char> );
44
45 BOOST_CHECK_TYPE3( tt::common_type< X<char>, X<unsigned char> >::type, X<int> );
46
47 BOOST_CHECK_TYPE3( tt::common_type< X<char>&, X<unsigned char>& >::type, X<int> );
48 BOOST_CHECK_TYPE3( tt::common_type< X<char>&, X<unsigned char> const& >::type, X<int> );
49 BOOST_CHECK_TYPE3( tt::common_type< X<char> const&, X<unsigned char>& >::type, X<int> );
50 BOOST_CHECK_TYPE3( tt::common_type< X<char> const&, X<unsigned char> const& >::type, X<int> );
51
52 // ternary
53
54 BOOST_CHECK_TYPE4( tt::common_type< X<char>&, X<long> const&, X<short> volatile& >::type, X<long> );
55 }
56 TT_TEST_END