// Copyright (C) 2016-2018 T. Zachary Laine // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #include #include template using term = boost::yap::terminal; template using ref = boost::yap::expression_ref; namespace yap = boost::yap; namespace bh = boost::hana; int test_main(int, char * []) { { term number = {{42}}; auto fn = yap::make_expression_function(number); auto fn_copy = fn; BOOST_CHECK(fn() == 42); BOOST_CHECK(fn_copy() == 42); yap::value(number) = 21; BOOST_CHECK(fn() == 21); BOOST_CHECK(fn_copy() == 21); } { term number = {{42}}; auto fn = yap::make_expression_function(std::move(number)); auto fn_copy = fn; BOOST_CHECK(fn() == 42); BOOST_CHECK(fn_copy() == 42); yap::value(number) = 21; BOOST_CHECK(fn() == 42); BOOST_CHECK(fn_copy() == 42); } { term> number = { {std::unique_ptr(new int(42))}}; auto fn = yap::make_expression_function(std::move(number)); BOOST_CHECK(*fn() == 42); auto fn_2 = std::move(fn); BOOST_CHECK(*fn_2() == 42); yap::value(number) = std::unique_ptr(new int(21)); BOOST_CHECK(*fn_2() == 42); } return 0; }