]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/type_traits/test/decay_test.cpp
2 // (C) Copyright John Maddock & Thorsten Ottosen 2005.
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.boost.org/LICENSE_1_0.txt)
8 # include <type_traits>
10 # include <boost/type_traits/decay.hpp>
11 # include <boost/type_traits/is_same.hpp>
14 #include "check_type.hpp"
15 #include "check_integral_constant.hpp"
21 // remark #383: value copied to temporary, reference to temporary used
22 // std::pair<std::string, int> p2 = boost::make_pair( "foo", 1 );
24 #pragma warning(disable:383)
40 // An almost optimal version of std::make_pair()
42 template< class F
, class S
>
43 inline std::pair
< BOOST_DEDUCED_TYPENAME
tt::decay
<const F
>::type
,
44 BOOST_DEDUCED_TYPENAME
tt::decay
<const S
>::type
>
45 make_pair( const F
& f
, const S
& s
)
47 return std::pair
< BOOST_DEDUCED_TYPENAME
tt::decay
<const F
>::type
,
48 BOOST_DEDUCED_TYPENAME
tt::decay
<const S
>::type
>( f
, s
);
52 This overload will mess up vc7.1
54 template< class F, class S >
55 inline std::pair< BOOST_DEDUCED_TYPENAME ::tt::decay<F>::type,
56 BOOST_DEDUCED_TYPENAME ::tt::decay<S>::type >
57 make_pair( F& f, S& s )
59 return std::pair< BOOST_DEDUCED_TYPENAME ::tt::decay<F>::type,
60 BOOST_DEDUCED_TYPENAME ::tt::decay<S>::type >( f, s );
65 BOOST_DECL_TRANSFORM_TEST3(decay_test_1
, ::tt::decay
, const)
66 BOOST_DECL_TRANSFORM_TEST3(decay_test_2
, ::tt::decay
, volatile)
67 BOOST_DECL_TRANSFORM_TEST3(decay_test_3
, ::tt::decay
, const volatile)
68 BOOST_DECL_TRANSFORM_TEST3(decay_test_4
, ::tt::decay
, const&)
69 BOOST_DECL_TRANSFORM_TEST3(decay_test_5
, ::tt::decay
, volatile&)
70 BOOST_DECL_TRANSFORM_TEST3(decay_test_6
, ::tt::decay
, const volatile&)
71 BOOST_DECL_TRANSFORM_TEST(decay_test_7
, ::tt::decay
, const*, const*)
72 BOOST_DECL_TRANSFORM_TEST(decay_test_8
, ::tt::decay
, [], *)
73 BOOST_DECL_TRANSFORM_TEST(decay_test_9
, ::tt::decay
, [2], *)
74 BOOST_DECL_TRANSFORM_TEST(decay_test_10
, ::tt::decay
, [2][3], (*)[3])
75 BOOST_DECL_TRANSFORM_TEST(decay_test_11
, ::tt::decay
, const[], const*)
76 BOOST_DECL_TRANSFORM_TEST(decay_test_12
, ::tt::decay
, const[2], const*)
77 BOOST_DECL_TRANSFORM_TEST(decay_test_13
, ::tt::decay
, const[2][3], const(*)[3])
78 BOOST_DECL_TRANSFORM_TEST(decay_test_14
, ::tt::decay
, (int), (*)(int))
98 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_same
<
99 ::tt::decay
<int>::type
,int>::value
),
101 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_same
<
102 ::tt::decay
<char[2]>::type
,char*>::value
),
104 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_same
<
105 ::tt::decay
<char[2][3]>::type
,char(*)[3]>::value
),
107 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_same
<
108 ::tt::decay
<const char[2]>::type
,const char*>::value
),
110 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_same
<
111 ::tt::decay
<wchar_t[2]>::type
,wchar_t*>::value
),
113 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_same
<
114 ::tt::decay
<const wchar_t[2]>::type
,const wchar_t*>::value
),
116 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_same
<
117 ::tt::decay
<const wchar_t[2]>::type
,const wchar_t*>::value
),
120 typedef int f1_type(void);
121 typedef int f2_type(int);
123 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_same
<
124 ::tt::decay
<f1_type
>::type
,int (*)(void)>::value
),
126 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_same
<
127 ::tt::decay
<f2_type
>::type
,int (*)(int)>::value
),
130 #ifndef BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS
132 // Don't test this if the std lib has no templated constructors (Oracle+STLPort):
134 std::pair
<std::string
,std::string
> p
= boost::make_pair( "foo", "bar" );
135 std::pair
<std::string
, int> p2
= boost::make_pair( "foo", 1 );
136 #ifndef BOOST_NO_STD_WSTRING
137 std::pair
<std::wstring
,std::string
> p3
= boost::make_pair( L
"foo", "bar" );
138 std::pair
<std::wstring
, int> p4
= boost::make_pair( L
"foo", 1 );
142 // Todo: make these work sometime. The test id not directly
143 // related to decay<T>::type and can be avoided for now.
147 std::pair<int*,int*> p5 = boost::make_pair( array, array );
148 #ifndef BOOST_BORLANDC
149 std::pair<int(*)(void), int(*)(int)> p6 = boost::make_pair(boost::proc1, boost::proc2);