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 "check_integral_constant.hpp"
10 # include <type_traits>
12 # include <boost/type_traits/decay.hpp>
13 # include <boost/type_traits/is_same.hpp>
20 // remark #383: value copied to temporary, reference to temporary used
21 // std::pair<std::string, int> p2 = boost::make_pair( "foo", 1 );
23 #pragma warning(disable:383)
39 // An almost optimal version of std::make_pair()
41 template< class F, class S >
42 inline std::pair< BOOST_DEDUCED_TYPENAME tt::decay<const F>::type,
43 BOOST_DEDUCED_TYPENAME tt::decay<const S>::type >
44 make_pair( const F& f, const S& s )
46 return std::pair< BOOST_DEDUCED_TYPENAME tt::decay<const F>::type,
47 BOOST_DEDUCED_TYPENAME tt::decay<const S>::type >( f, s );
51 This overload will mess up vc7.1
53 template< class F, class S >
54 inline std::pair< BOOST_DEDUCED_TYPENAME ::tt::decay<F>::type,
55 BOOST_DEDUCED_TYPENAME ::tt::decay<S>::type >
56 make_pair( F& f, S& s )
58 return std::pair< BOOST_DEDUCED_TYPENAME ::tt::decay<F>::type,
59 BOOST_DEDUCED_TYPENAME ::tt::decay<S>::type >( f, s );
64 TT_TEST_BEGIN(is_class)
66 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_same<
67 ::tt::decay<int>::type,int>::value),
69 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_same<
70 ::tt::decay<char[2]>::type,char*>::value),
72 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_same<
73 ::tt::decay<char[2][3]>::type,char(*)[3]>::value),
75 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_same<
76 ::tt::decay<const char[2]>::type,const char*>::value),
78 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_same<
79 ::tt::decay<wchar_t[2]>::type,wchar_t*>::value),
81 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_same<
82 ::tt::decay<const wchar_t[2]>::type,const wchar_t*>::value),
84 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_same<
85 ::tt::decay<const wchar_t[2]>::type,const wchar_t*>::value),
88 typedef int f1_type(void);
89 typedef int f2_type(int);
91 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_same<
92 ::tt::decay<f1_type>::type,int (*)(void)>::value),
94 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_same<
95 ::tt::decay<f2_type>::type,int (*)(int)>::value),
98 std::pair<std::string,std::string> p = boost::make_pair( "foo", "bar" );
99 std::pair<std::string, int> p2 = boost::make_pair( "foo", 1 );
100 #ifndef BOOST_NO_STD_WSTRING
101 std::pair<std::wstring,std::string> p3 = boost::make_pair( L"foo", "bar" );
102 std::pair<std::wstring, int> p4 = boost::make_pair( L"foo", 1 );
106 // Todo: make these work sometime. The test id not directly
107 // related to decay<T>::type and can be avioded for now.
111 std::pair<int*,int*> p5 = boost::make_pair( array, array );
113 std::pair<int(*)(void), int(*)(int)> p6 = boost::make_pair(boost::proc1, boost::proc2);