]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/yap/test/expression_function.cpp
4819e0f38564b4963bd9bb708aae793cf3b70e50
1 // Copyright (C) 2016-2018 T. Zachary Laine
3 // Distributed under the Boost Software License, Version 1.0. (See
4 // accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
6 #include <boost/yap/expression.hpp>
8 #include <boost/test/minimal.hpp>
12 using term
= boost::yap::terminal
<boost::yap::expression
, T
>;
15 using ref
= boost::yap::expression_ref
<boost::yap::expression
, T
>;
17 namespace yap
= boost::yap
;
18 namespace bh
= boost::hana
;
21 int test_main(int, char * [])
24 term
<int> number
= {{42}};
26 auto fn
= yap::make_expression_function(number
);
29 BOOST_CHECK(fn() == 42);
30 BOOST_CHECK(fn_copy() == 42);
32 yap::value(number
) = 21;
34 BOOST_CHECK(fn() == 21);
35 BOOST_CHECK(fn_copy() == 21);
39 term
<int> number
= {{42}};
41 auto fn
= yap::make_expression_function(std::move(number
));
44 BOOST_CHECK(fn() == 42);
45 BOOST_CHECK(fn_copy() == 42);
47 yap::value(number
) = 21;
49 BOOST_CHECK(fn() == 42);
50 BOOST_CHECK(fn_copy() == 42);
54 term
<std::unique_ptr
<int>> number
= {
55 {std::unique_ptr
<int>(new int(42))}};
57 auto fn
= yap::make_expression_function(std::move(number
));
59 BOOST_CHECK(*fn() == 42);
61 auto fn_2
= std::move(fn
);
62 BOOST_CHECK(*fn_2() == 42);
64 yap::value(number
) = std::unique_ptr
<int>(new int(21));
66 BOOST_CHECK(*fn_2() == 42);