]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/phoenix/test/function/lazy_make_pair_tests.cpp
1 ////////////////////////////////////////////////////////////////////////////
2 // lazy_make_pair_tests.cpp
4 // lazy make_pair test solving the optimizer problem.
6 ////////////////////////////////////////////////////////////////////////////
7 /*=============================================================================
8 Copyright (c) 2001-2007 Joel de Guzman
9 Copyright (c) 2015 John Fletcher
11 Distributed under the Boost Software License, Version 1.0. (See accompanying
12 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
13 ==============================================================================*/
15 #include <boost/phoenix/core/limits.hpp>
17 #include <boost/detail/lightweight_test.hpp>
18 #include <boost/phoenix/core.hpp>
19 #include <boost/phoenix/function.hpp>
25 #ifdef BOOST_RESULT_OF_USE_TR1
36 typedef typename
boost::remove_reference
<Arg1
>::type Arg1Type
;
37 typedef typename
boost::remove_reference
<Arg2
>::type Arg2Type
;
38 typedef std::pair
<Arg1Type
,Arg2Type
> type
;
49 #ifdef BOOST_RESULT_OF_USE_TR1
50 template <typename Sig
>
52 // This fails with -O2 unless refs are removed from A1 and A2.
53 template <typename This
, typename A0
, typename A1
>
54 struct result
<This(A0
, A1
)>
56 typedef typename
result_of::make_pair
<A0
,A1
>::type type
;
59 template <typename Sig
>
62 template <typename This
, typename A0
, typename A1
>
63 struct result
<This(A0
, A1
)>
64 : boost::remove_reference
<std::pair
<A0
, A1
> >
70 template <typename A0
, typename A1
>
71 #ifdef BOOST_RESULT_OF_USE_TR1
72 typename result
<make_pair(A0
,A1
)>::type
76 operator()(A0
const & a0
, A1
const & a1
) const
78 return std::make_pair(a0
,a1
);
84 BOOST_PHOENIX_ADAPT_CALLABLE(make_pair
, impl::make_pair
, 2)
92 namespace phx
= boost::phoenix
;
93 using boost::phoenix::arg_names::arg1
;
94 using boost::phoenix::arg_names::arg2
;
95 int a
= 99; int b
= 256;
97 std::pair
<int,int> ab1
= phx::make_pair(a
,b
)();
98 //std::cout << ab1.first << "," << ab1.second << std::endl;
99 BOOST_TEST(ab1
.first
== 99 && ab1
.second
== 256);
100 std::pair
<int,int> ab2
= phx::make_pair(arg1
,b
)(a
);
101 //std::cout << ab2.first << "," << ab2.second << std::endl;
102 BOOST_TEST(ab2
.first
== 99 && ab2
.second
== 256);
103 std::pair
<int,int> ab3
= phx::make_pair(arg1
,arg2
)(a
,b
);
104 //std::cout << ab3.first << "," << ab3.second << std::endl;
105 BOOST_TEST(ab3
.first
== 99 && ab3
.second
== 256);
108 return boost::report_errors();