]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/lambda/test/ret_test.cpp
1 // ret_test.cpp - The Boost Lambda Library -----------------------
3 // Copyright (C) 2009 Steven Watanabe
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)
9 // For more information, see www.boost.org
11 #include <boost/test/minimal.hpp>
13 #include <boost/lambda/lambda.hpp>
15 #include <boost/mpl/assert.hpp>
16 #include <boost/type_traits/is_same.hpp>
18 template<class R
, class F
>
19 void test_ret(R r
, F f
) {
20 typename
F::result_type x
= f();
21 BOOST_MPL_ASSERT((boost::is_same
<R
, typename
F::result_type
>));
25 template<class R
, class F
, class T1
>
26 void test_ret(R r
, F f
, T1
& t1
) {
27 typename
F::result_type x
= f(t1
);
28 BOOST_MPL_ASSERT((boost::is_same
<R
, typename
F::result_type
>));
34 add_result(int i
= 0) : value(i
) {}
35 friend bool operator==(const add_result
& lhs
, const add_result
& rhs
) {
36 return(lhs
.value
== rhs
.value
);
43 add_result
operator+(addable
, addable
) {
47 int test_main(int, char*[]) {
49 test_ret(add_result(7), boost::lambda::ret
<add_result
>(boost::lambda::_1
+ test
), test
);
50 test_ret(8.0, boost::lambda::ret
<double>(boost::lambda::constant(7) + 1));