summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/phoenix/test/function
diff options
context:
space:
mode:
Diffstat (limited to 'src/boost/libs/phoenix/test/function')
-rw-r--r--src/boost/libs/phoenix/test/function/adapt_function.cpp84
-rw-r--r--src/boost/libs/phoenix/test/function/function_tests.cpp140
-rw-r--r--src/boost/libs/phoenix/test/function/lazy_argument_tests.cpp53
-rw-r--r--src/boost/libs/phoenix/test/function/lazy_compose_tests.cpp40
-rw-r--r--src/boost/libs/phoenix/test/function/lazy_fold_tests.cpp44
-rw-r--r--src/boost/libs/phoenix/test/function/lazy_list2_tests.cpp42
-rw-r--r--src/boost/libs/phoenix/test/function/lazy_list3_tests.cpp54
-rw-r--r--src/boost/libs/phoenix/test/function/lazy_list_tests.cpp78
-rw-r--r--src/boost/libs/phoenix/test/function/lazy_make_pair_tests.cpp109
-rw-r--r--src/boost/libs/phoenix/test/function/lazy_operator_tests.cpp46
-rw-r--r--src/boost/libs/phoenix/test/function/lazy_ptr_tests.cpp110
-rw-r--r--src/boost/libs/phoenix/test/function/lazy_scan_tests.cpp56
-rw-r--r--src/boost/libs/phoenix/test/function/lazy_templated_struct_tests.cpp68
-rw-r--r--src/boost/libs/phoenix/test/function/lazy_thunk_tests.cpp48
14 files changed, 972 insertions, 0 deletions
diff --git a/src/boost/libs/phoenix/test/function/adapt_function.cpp b/src/boost/libs/phoenix/test/function/adapt_function.cpp
new file mode 100644
index 000000000..77cca41d8
--- /dev/null
+++ b/src/boost/libs/phoenix/test/function/adapt_function.cpp
@@ -0,0 +1,84 @@
+/*=============================================================================
+ Copyright (c) 2011 Thomas Heller
+ Copyright (c) 2015 John Fletcher
+
+ 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 <iostream>
+#include <cmath>
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/phoenix/core.hpp>
+#include <boost/phoenix/function.hpp>
+
+namespace impl
+{
+ void
+ test()
+ {
+ std::cout << "Test adapting functions...\n";
+ }
+
+ int
+ negate(int n)
+ {
+ return -n;
+ }
+
+ int
+ plus(int a, int b)
+ {
+ return a + b;
+ }
+
+ template <typename T>
+ T
+ plus(T a, T b, T c)
+ {
+ return a + b + c;
+ }
+
+ int
+ plus4(int a, int b, int c, int d)
+ {
+ return a + b + c + d;
+ }
+}
+
+BOOST_PHOENIX_ADAPT_FUNCTION_NULLARY(void, test, impl::test)
+BOOST_PHOENIX_ADAPT_FUNCTION(int, negate, impl::negate, 1)
+BOOST_PHOENIX_ADAPT_FUNCTION(int, plus, impl::plus, 2)
+BOOST_PHOENIX_ADAPT_FUNCTION(
+ typename boost::remove_reference<A0>::type
+ , plus
+ , impl::plus
+ , 3
+)
+BOOST_PHOENIX_ADAPT_FUNCTION(int, plus4, impl::plus4, 4)
+
+// Test of solution to bug when using namespace
+using namespace boost::phoenix;
+
+BOOST_PHOENIX_ADAPT_FUNCTION_NULLARY(void, test2, impl::test)
+BOOST_PHOENIX_ADAPT_FUNCTION(int, negate2, impl::negate, 1)
+
+
+int
+main()
+{
+ using boost::phoenix::arg_names::arg1;
+ using boost::phoenix::arg_names::arg2;
+
+ int a = 123;
+ int b = 256;
+
+ test()();
+ test2()();
+ BOOST_TEST(::negate(arg1)(a) == -a);
+ BOOST_TEST(::negate2(arg1)(a) == -a);
+ BOOST_TEST(::plus(arg1, arg2)(a, b) == a+b);
+ BOOST_TEST(::plus(arg1, arg2, 3)(a, b) == a+b+3);
+ BOOST_TEST(plus4(arg1, arg2, 3, 4)(a, b) == a+b+3+4);
+
+ return boost::report_errors();
+}
diff --git a/src/boost/libs/phoenix/test/function/function_tests.cpp b/src/boost/libs/phoenix/test/function/function_tests.cpp
new file mode 100644
index 000000000..6f979fafe
--- /dev/null
+++ b/src/boost/libs/phoenix/test/function/function_tests.cpp
@@ -0,0 +1,140 @@
+/*=============================================================================
+ Copyright (c) 2001-2007 Joel de Guzman
+
+ 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 <iostream>
+#include <cmath>
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/phoenix/core.hpp>
+#include <boost/phoenix/operator.hpp>
+#include <boost/phoenix/function.hpp>
+
+#define BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
+#include <boost/mpl/multiplies.hpp>
+#undef BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
+
+struct test_impl
+{
+ typedef void result_type;
+ void operator()() const
+ {
+ std::cout << "Test lazy functions...\n";
+ }
+};
+
+boost::phoenix::function<test_impl> test;
+
+struct sqr_impl
+{
+ template <typename Signature>
+ struct result;
+
+ template <typename This, typename Arg>
+ struct result<This(Arg)>
+ {
+ typedef typename boost::remove_reference<Arg>::type type;
+ };
+
+ template <typename Arg>
+ Arg
+ operator()(Arg n) const
+ {
+ return n * n;
+ }
+};
+
+boost::phoenix::function<sqr_impl> sqr;
+
+struct fact_impl
+{
+ template <typename Signature>
+ struct result;
+
+ template <typename This, typename Arg>
+ struct result<This(Arg)>
+ {
+ typedef typename boost::remove_reference<Arg>::type type;
+ };
+
+ template <typename Arg>
+ Arg
+ operator()(Arg n) const
+ {
+ return (n <= 0) ? 1 : n * (*this)(n-1);
+ }
+};
+
+boost::phoenix::function<fact_impl> fact;
+
+struct pow_impl
+{
+
+ template <typename Sig>
+ struct result;
+
+ template <typename This, typename Arg1, typename Arg2>
+ struct result<This(Arg1, Arg2)>
+ {
+ typedef typename boost::remove_reference<Arg1>::type type;
+ };
+
+ template <typename Arg1, typename Arg2>
+ Arg1
+ operator()(Arg1 a, Arg2 b) const
+ {
+ return std::pow(a, b);
+ }
+};
+
+boost::phoenix::function<pow_impl> power;
+
+struct add_impl
+{
+ template <typename Sig>
+ struct result;
+
+ template <typename This, typename Arg1, typename Arg2, typename Arg3, typename Arg4>
+ struct result<This(Arg1, Arg2, Arg3, Arg4)>
+ {
+ typedef typename boost::remove_reference<Arg1>::type type;
+ };
+
+ template <typename Arg1, typename Arg2, typename Arg3, typename Arg4>
+ Arg1
+ operator()(Arg1 a, Arg2 b, Arg3 c, Arg4 d) const
+ {
+ return a + b + c + d;
+ }
+};
+
+boost::phoenix::function<add_impl> add;
+
+int
+main()
+{
+ using boost::phoenix::arg_names::arg1;
+ using boost::phoenix::arg_names::arg2;
+
+ int i5 = 5;
+ double d5 = 5, d3 = 3;
+
+ test()();
+ BOOST_TEST(sqr(arg1)(i5) == (i5*i5));
+ BOOST_TEST(fact(4)() == 24);
+ BOOST_TEST(fact(arg1)(i5) == 120);
+ BOOST_TEST((int)power(arg1, arg2)(d5, d3) == (int)std::pow(d5, d3));
+ BOOST_TEST((sqr(arg1) + 5)(i5) == ((i5*i5)+5));
+ BOOST_TEST(add(arg1, arg1, arg1, arg1)(i5) == (5+5+5+5));
+
+ // testing composition
+ BOOST_TEST(add(arg1, arg1, arg1, power(arg1, 2))(d5) == (5+5+5+25));
+
+ int const ic5 = 5;
+ // testing consts
+ BOOST_TEST(sqr(arg1)(ic5) == (ic5*ic5));
+
+ return boost::report_errors();
+}
diff --git a/src/boost/libs/phoenix/test/function/lazy_argument_tests.cpp b/src/boost/libs/phoenix/test/function/lazy_argument_tests.cpp
new file mode 100644
index 000000000..a45f501f1
--- /dev/null
+++ b/src/boost/libs/phoenix/test/function/lazy_argument_tests.cpp
@@ -0,0 +1,53 @@
+////////////////////////////////////////////////////////////////////////////
+// lazy_argument_tests.cpp
+//
+// lazy argument tests passing lazy function as argument.
+//
+////////////////////////////////////////////////////////////////////////////
+/*=============================================================================
+ Copyright (c) 2001-2007 Joel de Guzman
+ Copyright (c) 2015 John Fletcher
+
+ 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 <boost/phoenix/core/limits.hpp>
+
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/phoenix/core.hpp>
+#include <boost/phoenix/function.hpp>
+
+namespace example {
+ struct G {
+
+ template <typename Sig>
+ struct result;
+
+ template <typename This, typename A0>
+ struct result<This(A0)>
+ : boost::remove_reference<A0>
+ {};
+
+ template <typename T>
+ T operator()(T t) const { return ++t; }
+
+ };
+}
+
+typedef boost::phoenix::function<example::G> GG;
+boost::phoenix::function<example::G> gg;
+
+template <typename F,typename T>
+T h(F f, T const& t)
+{
+ return f(t)();
+}
+
+int main()
+{
+ BOOST_TEST( h(gg,1) == 2);
+ BOOST_TEST(( h<GG,int>(gg,1) == 2));
+
+ return boost::report_errors();
+}
diff --git a/src/boost/libs/phoenix/test/function/lazy_compose_tests.cpp b/src/boost/libs/phoenix/test/function/lazy_compose_tests.cpp
new file mode 100644
index 000000000..ea031e32c
--- /dev/null
+++ b/src/boost/libs/phoenix/test/function/lazy_compose_tests.cpp
@@ -0,0 +1,40 @@
+////////////////////////////////////////////////////////////////////////////
+// lazy_compose_tests.cpp
+//
+// tests on compose
+//
+////////////////////////////////////////////////////////////////////////////
+/*=============================================================================
+ Copyright (c) 2000-2003 Brian McNamara and Yannis Smaragdakis
+ Copyright (c) 2001-2007 Joel de Guzman
+ Copyright (c) 2015 John Fletcher
+
+ 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 <boost/phoenix/core/limits.hpp>
+
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/phoenix/core.hpp>
+#include <boost/phoenix/function/lazy_prelude.hpp>
+
+
+int main()
+{
+ namespace phx = boost::phoenix;
+ using boost::phoenix::arg_names::arg1;
+ using boost::phoenix::arg_names::arg2;
+ using namespace phx;
+
+ BOOST_TEST(compose(id,id)(arg1)(1) == 1);
+ BOOST_TEST(compose(id,id)(1)() == 1);
+ BOOST_TEST(compose(inc,inc)(arg1)(1) == 3);
+ BOOST_TEST(compose(inc,plus)(arg1,arg2)(2,3) == 6);
+ BOOST_TEST(compose(plus,inc,dec)(arg1)(1) == 2);
+ BOOST_TEST(compose(plus,plus,minus)(arg1,arg2)(3,1) == 6);
+
+
+
+ return boost::report_errors();
+}
diff --git a/src/boost/libs/phoenix/test/function/lazy_fold_tests.cpp b/src/boost/libs/phoenix/test/function/lazy_fold_tests.cpp
new file mode 100644
index 000000000..5c542575d
--- /dev/null
+++ b/src/boost/libs/phoenix/test/function/lazy_fold_tests.cpp
@@ -0,0 +1,44 @@
+////////////////////////////////////////////////////////////////////////////
+// lazy_fold_tests.cpp
+//
+// tests on foldl foldr and compose
+//
+////////////////////////////////////////////////////////////////////////////
+/*=============================================================================
+ Copyright (c) 2000-2003 Brian McNamara and Yannis Smaragdakis
+ Copyright (c) 2001-2007 Joel de Guzman
+ Copyright (c) 2015 John Fletcher
+
+ 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 <boost/phoenix/core/limits.hpp>
+
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/phoenix/core.hpp>
+#include <boost/phoenix/function/lazy_prelude.hpp>
+
+
+int main()
+{
+ namespace phx = boost::phoenix;
+ using boost::phoenix::arg_names::arg1;
+ using boost::phoenix::arg_names::arg2;
+ using boost::phoenix::arg_names::arg3;
+ using namespace phx;
+
+ list<int> l = enum_from(2);
+ list<int> evens = filter(even,l);
+ list<int> even4 = take(4,evens)();
+
+ BOOST_TEST(foldr(plus,0,even4)() == 20);
+ BOOST_TEST(foldr(multiplies,1,even4)() == 384);
+ BOOST_TEST(foldr1(plus,even4)() == 20 );
+ BOOST_TEST(foldl(plus,arg1,even4)(0) == 20);
+ BOOST_TEST(foldl1(plus,even4)() == 20);
+ BOOST_TEST(compose(inc,foldr)(plus,0,even4)() == 21);
+ BOOST_TEST(compose(plus,foldl,foldr)(arg1,arg2,arg3)(plus,0,even4) == 40);
+
+ return boost::report_errors();
+}
diff --git a/src/boost/libs/phoenix/test/function/lazy_list2_tests.cpp b/src/boost/libs/phoenix/test/function/lazy_list2_tests.cpp
new file mode 100644
index 000000000..c294a8f89
--- /dev/null
+++ b/src/boost/libs/phoenix/test/function/lazy_list2_tests.cpp
@@ -0,0 +1,42 @@
+////////////////////////////////////////////////////////////////////////////
+// lazy_list2_tests.cpp
+//
+// more tests on list<T>
+//
+////////////////////////////////////////////////////////////////////////////
+/*=============================================================================
+ Copyright (c) 2000-2003 Brian McNamara and Yannis Smaragdakis
+ Copyright (c) 2001-2007 Joel de Guzman
+ Copyright (c) 2015 John Fletcher
+
+ 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 <boost/phoenix/core/limits.hpp>
+
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/phoenix/core.hpp>
+#include <boost/phoenix/function/lazy_prelude.hpp>
+
+
+int main()
+{
+ namespace phx = boost::phoenix;
+ using boost::phoenix::arg_names::arg1;
+ using boost::phoenix::arg_names::arg2;
+ using namespace phx;
+
+ list<int> l0;
+ list<int> l1 = list_with<>()(1,2,3,4,5);
+ list<int> l2 = all_but_last(l1)();
+
+ BOOST_TEST(null(l0)());
+ BOOST_TEST(head(l1)() == 1);
+ BOOST_TEST(head(tail(l1))() == 2);
+ BOOST_TEST(last(l1)() == 5);
+ BOOST_TEST(last(l2)() == 4);
+ BOOST_TEST(head(drop(2,l2))() == 3);
+
+ return boost::report_errors();
+}
diff --git a/src/boost/libs/phoenix/test/function/lazy_list3_tests.cpp b/src/boost/libs/phoenix/test/function/lazy_list3_tests.cpp
new file mode 100644
index 000000000..9e4bc6d0d
--- /dev/null
+++ b/src/boost/libs/phoenix/test/function/lazy_list3_tests.cpp
@@ -0,0 +1,54 @@
+////////////////////////////////////////////////////////////////////////////
+// lazy_list3_tests.cpp
+//
+// more tests on list<T>
+//
+////////////////////////////////////////////////////////////////////////////
+/*=============================================================================
+ Copyright (c) 2000-2003 Brian McNamara and Yannis Smaragdakis
+ Copyright (c) 2001-2007 Joel de Guzman
+ Copyright (c) 2015 John Fletcher
+
+ 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 <boost/phoenix/core/limits.hpp>
+
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/phoenix/core.hpp>
+#include <boost/phoenix/function/lazy_prelude.hpp>
+
+
+int main()
+{
+ namespace phx = boost::phoenix;
+ //using boost::phoenix::arg_names::arg1;
+ //using boost::phoenix::arg_names::arg2;
+ using namespace phx;
+
+ list<int> l = enum_from(2);
+ list<int> ll = take(4,l);
+ list<int> lll = take(12,l);
+ list<int> l2 = enum_from_to(2,10);
+ list<int> ll2 = take(4,l2);
+ list<int> lll2 = take(12,l2);
+ list<int> evens = filter(even,l);
+ list<int> odds = filter(odd,l);
+ list<int> even4 = take(4,evens)();
+ list<int> odd4 = take(4,odds)();
+ list<int> itersome = take(4,iterate(dec,1))();
+ list<int> repeatsome = take(4,repeat(1))();
+
+ BOOST_TEST(last(ll)() == 5);
+ BOOST_TEST(last(lll)() == 13);
+ BOOST_TEST(last(ll2)() == 5);
+ BOOST_TEST(last(lll2)() == 10);
+ BOOST_TEST(length(lll2)() == 9);
+ BOOST_TEST(at_(even4,3)() == 8);
+ BOOST_TEST(at_(odd4,2)() == 7);
+ BOOST_TEST(at_(itersome,3)() == -3);
+ BOOST_TEST(at_(repeatsome,3)() == 1);
+
+ return boost::report_errors();
+}
diff --git a/src/boost/libs/phoenix/test/function/lazy_list_tests.cpp b/src/boost/libs/phoenix/test/function/lazy_list_tests.cpp
new file mode 100644
index 000000000..47caf6496
--- /dev/null
+++ b/src/boost/libs/phoenix/test/function/lazy_list_tests.cpp
@@ -0,0 +1,78 @@
+////////////////////////////////////////////////////////////////////////////
+// lazy_list_tests.cpp
+//
+// tests on list<T>
+//
+////////////////////////////////////////////////////////////////////////////
+/*=============================================================================
+ Copyright (c) 2000-2003 Brian McNamara and Yannis Smaragdakis
+ Copyright (c) 2001-2007 Joel de Guzman
+ Copyright (c) 2015 John Fletcher
+
+ 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 <boost/phoenix/core/limits.hpp>
+
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/phoenix/core.hpp>
+#include <boost/phoenix/function/lazy_prelude.hpp>
+
+
+int main()
+{
+ namespace phx = boost::phoenix;
+ using boost::phoenix::arg_names::arg1;
+ using boost::phoenix::arg_names::arg2;
+ using phx::null;
+ using phx::list;
+ using phx::head;
+ using phx::tail;
+ using phx::cons;
+ using phx::cat;
+ using phx::take;
+ using phx::NIL;
+
+ list<int> l0;
+ list<int> l1 = cons(1,l0);
+ list<int> l2 = cons(2,l1);
+ list<int> l3 = cons(3,l2);
+ list<int> l4 = cons(4,l3);
+ list<int> l5 = cons(5,NIL);
+ list<int> l6 = take(2,l4)();
+ list<int> l7 = cons(7,take(2,l4));
+ list<int> l8 = take(1,take(3,l4))();
+
+ BOOST_TEST(null(l0)());
+ BOOST_TEST(null(arg1)(l0));
+ BOOST_TEST(head(l1)() == 1);
+ BOOST_TEST(head(arg1)(l1) == 1);
+ BOOST_TEST(head(tail(l2))() == 1);
+ BOOST_TEST(head(tail(arg1))(l2) == 1);
+ BOOST_TEST(head(tail(tail(l3)))() == 1);
+ BOOST_TEST(head(tail(tail(arg1)))(l3) == 1);
+ BOOST_TEST(head(tail(tail(l4)))() == 2);
+ BOOST_TEST(head(tail(tail(arg1)))(l4) == 2);
+ BOOST_TEST(head(l5)() == 5);
+ BOOST_TEST(head(arg1)(l5) == 5);
+ BOOST_TEST(head(tail(l6))() == 3);
+ BOOST_TEST(head(tail(arg1))(l6) == 3);
+ BOOST_TEST(head(tail(l7))() == 4);
+ BOOST_TEST(head(tail(arg1))(l7) == 4);
+ BOOST_TEST(head(l8)() == 4);
+ BOOST_TEST(head(arg1)(l8) == 4);
+
+ list<int> l9 = cat(l8,take(2,l4));
+ list<int> l10 = cat(l8,NIL);
+ list<int> l11 = cat(l0,l7);
+ list<int> l12 = cat(l10,l8);
+
+ BOOST_TEST(head(tail(l9))() == 4);
+ BOOST_TEST(head(l10)() == 4);
+ BOOST_TEST(head(arg1)(l11) == 7);
+ BOOST_TEST(head(l12)() == 4);
+
+
+ return boost::report_errors();
+}
diff --git a/src/boost/libs/phoenix/test/function/lazy_make_pair_tests.cpp b/src/boost/libs/phoenix/test/function/lazy_make_pair_tests.cpp
new file mode 100644
index 000000000..09fccf5c2
--- /dev/null
+++ b/src/boost/libs/phoenix/test/function/lazy_make_pair_tests.cpp
@@ -0,0 +1,109 @@
+////////////////////////////////////////////////////////////////////////////
+// lazy_make_pair_tests.cpp
+//
+// lazy make_pair test solving the optimizer problem.
+//
+////////////////////////////////////////////////////////////////////////////
+/*=============================================================================
+ Copyright (c) 2001-2007 Joel de Guzman
+ Copyright (c) 2015 John Fletcher
+
+ 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 <boost/phoenix/core/limits.hpp>
+
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/phoenix/core.hpp>
+#include <boost/phoenix/function.hpp>
+
+namespace boost {
+
+ namespace phoenix {
+
+#ifdef BOOST_RESULT_OF_USE_TR1
+
+ namespace result_of {
+
+ template <
+ typename Arg1
+ , typename Arg2
+ >
+ class make_pair
+ {
+ public:
+ typedef typename boost::remove_reference<Arg1>::type Arg1Type;
+ typedef typename boost::remove_reference<Arg2>::type Arg2Type;
+ typedef std::pair<Arg1Type,Arg2Type> type;
+ };
+ }
+#endif
+
+ namespace impl
+ {
+
+ struct make_pair {
+
+
+#ifdef BOOST_RESULT_OF_USE_TR1
+ template <typename Sig>
+ struct result;
+ // This fails with -O2 unless refs are removed from A1 and A2.
+ template <typename This, typename A0, typename A1>
+ struct result<This(A0, A1)>
+ {
+ typedef typename result_of::make_pair<A0,A1>::type type;
+ };
+#else
+ template <typename Sig>
+ struct result;
+
+ template <typename This, typename A0, typename A1>
+ struct result<This(A0, A1)>
+ : boost::remove_reference<std::pair<A0, A1> >
+ {};
+
+#endif
+
+
+ template <typename A0, typename A1>
+#ifdef BOOST_RESULT_OF_USE_TR1
+ typename result<make_pair(A0,A1)>::type
+#else
+ std::pair<A0, A1>
+#endif
+ operator()(A0 const & a0, A1 const & a1) const
+ {
+ return std::make_pair(a0,a1);
+ }
+
+ };
+ }
+
+BOOST_PHOENIX_ADAPT_CALLABLE(make_pair, impl::make_pair, 2)
+
+ }
+
+}
+
+int main()
+{
+ namespace phx = boost::phoenix;
+ using boost::phoenix::arg_names::arg1;
+ using boost::phoenix::arg_names::arg2;
+ int a = 99; int b = 256;
+
+ std::pair<int,int> ab1 = phx::make_pair(a,b)();
+ //std::cout << ab1.first << "," << ab1.second << std::endl;
+ BOOST_TEST(ab1.first == 99 && ab1.second == 256);
+ std::pair<int,int> ab2 = phx::make_pair(arg1,b)(a);
+ //std::cout << ab2.first << "," << ab2.second << std::endl;
+ BOOST_TEST(ab2.first == 99 && ab2.second == 256);
+ std::pair<int,int> ab3 = phx::make_pair(arg1,arg2)(a,b);
+ //std::cout << ab3.first << "," << ab3.second << std::endl;
+ BOOST_TEST(ab3.first == 99 && ab3.second == 256);
+
+
+ return boost::report_errors();
+}
diff --git a/src/boost/libs/phoenix/test/function/lazy_operator_tests.cpp b/src/boost/libs/phoenix/test/function/lazy_operator_tests.cpp
new file mode 100644
index 000000000..ef05717c8
--- /dev/null
+++ b/src/boost/libs/phoenix/test/function/lazy_operator_tests.cpp
@@ -0,0 +1,46 @@
+////////////////////////////////////////////////////////////////////////////
+// lazy_operator_tests.cpp
+//
+// lazy operator tests
+//
+////////////////////////////////////////////////////////////////////////////
+/*=============================================================================
+ Copyright (c) 2000-2003 Brian McNamara and Yannis Smaragdakis
+ Copyright (c) 2001-2007 Joel de Guzman
+ Copyright (c) 2015 John Fletcher
+
+ 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 <boost/phoenix/core/limits.hpp>
+
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/phoenix/core.hpp>
+#include <boost/phoenix/function/lazy_operator.hpp>
+
+
+int main()
+{
+ using boost::phoenix::plus;
+ using boost::phoenix::minus;
+ using boost::phoenix::arg_names::arg1;
+ using boost::phoenix::arg_names::arg2;
+
+ int a = 123;
+ int b = 256;
+
+ BOOST_TEST(plus(arg1, arg2)(a, b) == a+b);
+ BOOST_TEST(plus(arg1, arg2, 3)(a, b) == a+b+3);
+ BOOST_TEST(plus(arg1, b)(a) == a+b);
+ BOOST_TEST(plus(a, arg2)(a,b) == a+b);
+ BOOST_TEST(plus(a, arg1)(b) == a+b);
+ BOOST_TEST(plus(a, b)() == a+b);
+ BOOST_TEST(minus(a, b)() == a-b);
+ BOOST_TEST(plus(minus(a, b),b)() == a);
+ BOOST_TEST(plus(minus(arg1, b),b)(a) == a);
+ BOOST_TEST(plus(minus(arg1, arg2),b)(a,b) == a);
+ BOOST_TEST(plus(minus(arg1, arg2),arg2)(a,b) ==a);
+
+ return boost::report_errors();
+}
diff --git a/src/boost/libs/phoenix/test/function/lazy_ptr_tests.cpp b/src/boost/libs/phoenix/test/function/lazy_ptr_tests.cpp
new file mode 100644
index 000000000..22b1f1576
--- /dev/null
+++ b/src/boost/libs/phoenix/test/function/lazy_ptr_tests.cpp
@@ -0,0 +1,110 @@
+//////////////////////////////////////////////////////////////////
+//
+// lazy_ptr_tests.cpp
+//
+// Tests for ptr_to_fun, ptr_to_fun0 and ptr_to_mem_fun.
+//
+//
+/*=============================================================================
+ Copyright (c) 2000-2003 Brian McNamara and Yannis Smaragdakis
+ Copyright (c) 2001-2007 Joel de Guzman
+ Copyright (c) 2015 John Fletcher
+
+ 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 <iostream>
+#include <boost/phoenix/core.hpp>
+#include <boost/phoenix/function.hpp>
+#include <boost/shared_ptr.hpp>
+#include <boost/phoenix/function/lazy_prelude.hpp>
+
+#include <boost/detail/lightweight_test.hpp>
+
+using namespace boost::phoenix;
+
+using std::cout;
+using std::endl;
+
+namespace example {
+
+ int footle()
+ {
+ return 0;
+ }
+
+ int foobar(int x)
+ {
+ return 2*x;
+ }
+
+ int foxy(int x,int y)
+ {
+ return x*y;
+ }
+
+ int foxyz(int x,int y,int z)
+ {
+ return x*y + z;
+ }
+
+ int fwxyz(int w,int x,int y,int z)
+ {
+ return w + x*y + z;
+ }
+
+}
+
+struct O {
+ int aa;
+ O( int a ) : aa(a) {}
+ int cf( int x ) const { return x+1; }
+ int f( int x ) { return ++aa + x; }
+ int a() const { return aa; }
+};
+
+
+int main() {
+ using boost::phoenix::arg_names::arg1;
+ using boost::phoenix::arg_names::arg2;
+ using boost::phoenix::arg_names::arg3;
+ using boost::phoenix::arg_names::arg4;
+
+ BOOST_TEST( ptr_to_fun0(&example::footle)()() == 0 );
+ BOOST_TEST( ptr_to_fun(&example::foobar)(arg1)(1) == 2 );
+ BOOST_TEST( ptr_to_fun(&example::foxy)(arg1,arg2)(2,3) == 6 );
+ BOOST_TEST( ptr_to_fun(&example::foxyz)(arg1,arg2,arg3)(2,3,4) == 10 );
+ BOOST_TEST( ptr_to_fun(&example::fwxyz)(arg1,arg2,arg3,arg4)(1,2,3,4) == 11);
+
+ O o(1);
+ BOOST_TEST( ptr_to_mem_fun( &O::a )( &o )() == 1 );
+ BOOST_TEST( ptr_to_mem_fun( &O::cf )( &o, 1 )() == 2 );
+ BOOST_TEST( ptr_to_mem_fun( &O::f )( &o, 1 )() == 3 );
+ BOOST_TEST( ptr_to_mem_fun( &O::f )( &o, 1 )() == 4 );
+ BOOST_TEST( ptr_to_mem_fun( &O::cf )( &o, 1 )() == 2 );
+
+ O oo(1);
+ BOOST_TEST( ptr_to_mem_fun( &O::a )( arg1 )( &oo ) == 1 );
+ BOOST_TEST( ptr_to_mem_fun( &O::cf )( &oo, arg1 )(1) == 2 );
+ BOOST_TEST( ptr_to_mem_fun( &O::f )( &oo, arg1 )(1) == 3 );
+ BOOST_TEST( ptr_to_mem_fun( &O::f )( &oo, arg1 )(1) == 4 );
+ BOOST_TEST( ptr_to_mem_fun( &O::cf )( &oo, arg1 )(1) == 2 );
+
+ const O p(1);
+ BOOST_TEST( ptr_to_mem_fun( &O::a )( &p )() == 1 );
+ BOOST_TEST( ptr_to_mem_fun( &O::cf )( &p, 1 )() == 2 );
+
+ boost::shared_ptr<O> r( new O(3) );
+ BOOST_TEST( ptr_to_mem_fun( &O::a )( r )() == 3 );
+ BOOST_TEST( ptr_to_mem_fun( &O::cf )( r, 1 )() == 2 );
+ BOOST_TEST( ptr_to_mem_fun( &O::f )( r, 1 )() == 5 );
+ BOOST_TEST( ptr_to_mem_fun( &O::f )( r, 1 )() == 6 );
+ BOOST_TEST( ptr_to_mem_fun( &O::cf )( r, 1 )() == 2 );
+
+ boost::shared_ptr<const O> s( new O(3) );
+ BOOST_TEST( ptr_to_mem_fun( &O::a )( s )() == 3 );
+ BOOST_TEST( ptr_to_mem_fun( &O::cf )( s, 1 )() == 2 );
+
+ return boost::report_errors();
+}
diff --git a/src/boost/libs/phoenix/test/function/lazy_scan_tests.cpp b/src/boost/libs/phoenix/test/function/lazy_scan_tests.cpp
new file mode 100644
index 000000000..0567951b5
--- /dev/null
+++ b/src/boost/libs/phoenix/test/function/lazy_scan_tests.cpp
@@ -0,0 +1,56 @@
+////////////////////////////////////////////////////////////////////////////
+// lazy_scan_tests.cpp
+//
+// tests on scanl scanr map zip and zip_with
+//
+////////////////////////////////////////////////////////////////////////////
+/*=============================================================================
+ Copyright (c) 2000-2003 Brian McNamara and Yannis Smaragdakis
+ Copyright (c) 2001-2007 Joel de Guzman
+ Copyright (c) 2015 John Fletcher
+
+ 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 <boost/phoenix/core/limits.hpp>
+
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/phoenix/core.hpp>
+#include <boost/phoenix/function/lazy_prelude.hpp>
+
+
+int main()
+{
+ namespace phx = boost::phoenix;
+ using boost::phoenix::arg_names::arg1;
+ using boost::phoenix::arg_names::arg2;
+ using boost::phoenix::arg_names::arg3;
+ using namespace phx;
+
+ list<int> l = enum_from(2);
+ list<int> evens = filter(even,l);
+ list<int> odds = filter(odd,l);
+ list<int> even4 = take(4,evens)();
+ list<int> odd4 = take(4,odds)();
+
+ BOOST_TEST(head(scanr(plus,0,even4))() == 20);
+ BOOST_TEST(last(scanl(plus,0,even4))() == 20);
+ BOOST_TEST(head(scanr1(plus,even4))() == 20);
+ BOOST_TEST(last(scanl1(plus,even4))() == 20);
+
+ list<int> map_result = map(inc,even4)();
+ list<int> zip_with_result = zip_with(plus,even4,odd4)();
+
+ BOOST_TEST(foldl1(plus,map_result)() == 24);
+ BOOST_TEST(last(zip_with_result)() == 17);
+
+ typedef std::pair<int,int> pair_ii;
+ list<pair_ii> zip_result1 = zip_with(make_pair,even4,odd4)();
+ list<pair_ii> zip_result2 = zip(even4,odd4)();
+
+ BOOST_TEST(head(zip_result1)().first == 2);
+ BOOST_TEST(last(zip_result2)().second == 9);
+
+ return boost::report_errors();
+}
diff --git a/src/boost/libs/phoenix/test/function/lazy_templated_struct_tests.cpp b/src/boost/libs/phoenix/test/function/lazy_templated_struct_tests.cpp
new file mode 100644
index 000000000..b7c990435
--- /dev/null
+++ b/src/boost/libs/phoenix/test/function/lazy_templated_struct_tests.cpp
@@ -0,0 +1,68 @@
+////////////////////////////////////////////////////////////////////////////
+// lazy_templated_struct_tests.cpp
+//
+// lazy templated struct test to check this works everywhere.
+//
+////////////////////////////////////////////////////////////////////////////
+/*=============================================================================
+ Copyright (c) 2001-2007 Joel de Guzman
+ Copyright (c) 2015 John Fletcher
+
+ 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 <boost/phoenix/core/limits.hpp>
+
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/phoenix/core.hpp>
+#include <boost/phoenix/function.hpp>
+#include <boost/function.hpp>
+
+namespace example {
+
+ namespace impl {
+ // Example of templated struct.
+ template <typename Result>
+ struct what {
+
+ typedef Result result_type;
+
+ Result operator()(Result const & r) const
+ {
+ return r;
+ }
+ };
+
+ template <typename Result>
+ struct what0 {
+
+ typedef Result result_type;
+
+ Result operator()() const
+ {
+ return Result(100);
+ }
+
+ };
+
+ }
+
+ boost::function1<int, int > what_int = impl::what<int>();
+ boost::function0<int> what0_int = impl::what0<int>();
+ BOOST_PHOENIX_ADAPT_FUNCTION(int,what,what_int,1)
+ BOOST_PHOENIX_ADAPT_FUNCTION_NULLARY(int,what0,what0_int)
+}
+
+int main()
+{
+ int a = 99;
+ using boost::phoenix::arg_names::arg1;
+ BOOST_TEST(example::what_int(a) == a);
+ BOOST_TEST(example::what(a)() == a);
+ BOOST_TEST(example::what(arg1)(a) == a);
+ BOOST_TEST(example::what0_int() == 100);
+ BOOST_TEST(example::what0()() == 100);
+
+ return boost::report_errors();
+}
diff --git a/src/boost/libs/phoenix/test/function/lazy_thunk_tests.cpp b/src/boost/libs/phoenix/test/function/lazy_thunk_tests.cpp
new file mode 100644
index 000000000..f44e991e5
--- /dev/null
+++ b/src/boost/libs/phoenix/test/function/lazy_thunk_tests.cpp
@@ -0,0 +1,48 @@
+//////////////////////////////////////////////////////////////////
+//
+// lazy_thunk_tests.cpp
+//
+// Tests for thunk functions.
+//
+//
+/*=============================================================================
+ Copyright (c) 2000-2003 Brian McNamara and Yannis Smaragdakis
+ Copyright (c) 2001-2007 Joel de Guzman
+ Copyright (c) 2015 John Fletcher
+
+ 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 <iostream>
+#include <boost/phoenix/core.hpp>
+#include <boost/phoenix/function.hpp>
+#include <boost/shared_ptr.hpp>
+#include <boost/phoenix/function/lazy_prelude.hpp>
+
+#include <boost/detail/lightweight_test.hpp>
+
+using namespace boost::phoenix;
+
+using std::cout;
+using std::endl;
+
+
+
+int main() {
+ using boost::phoenix::arg_names::arg1;
+ using boost::phoenix::arg_names::arg2;
+
+ BOOST_TEST( thunk1(inc,1)()() == 2);
+ BOOST_TEST( thunk1(inc,arg1)(1)() == 2);
+ BOOST_TEST( thunk2(plus,1,2)()() == 3);
+ BOOST_TEST( thunk2(plus,arg1,arg2)(1,2)() == 3);
+
+ list<int> l = enum_from_to(1,5);
+ list<int> l4 = take(4,l)();
+ BOOST_TEST( foldl(plus,0,l4)() == 10);
+ BOOST_TEST( thunk3(foldl,plus,0,l4)()() == 10);
+ BOOST_TEST( thunk3(foldl,plus,arg1,l4)(0)() == 10);
+
+ return boost::report_errors();
+}