2
0
mirror of https://github.com/boostorg/phoenix.git synced 2026-02-01 08:42:14 +00:00

+ added full support for function composition/chaining

[SVN r63785]
This commit is contained in:
Thomas Heller
2010-07-09 18:24:28 +00:00
parent 1b02224e75
commit 4f0d6249a9
10 changed files with 251 additions and 90 deletions

View File

@@ -0,0 +1,38 @@
/*=============================================================================
Copyright (c) 2001-2007 Joel de Guzman
Copyright (c) 2010 Thomas Heller
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/operator.hpp>
#include <boost/phoenix/function.hpp>
#include <boost/detail/lightweight_test.hpp>
using boost::phoenix::arg_names::arg1;
using boost::phoenix::arg_names::arg2;
using boost::phoenix::arg_names::arg3;
int main()
{
/*
auto square = arg1 * arg1;
auto cube = arg1 * arg1 * arg1;
auto square_cube = square(cube(arg1));
*/
BOOST_TEST(((arg1 * arg1)(arg1 * arg1 * arg1))(2) == 64);
BOOST_TEST(((arg1 * arg1)(arg1 * arg2 * arg1))(2, 2) == 64);
BOOST_TEST(((arg1 * arg1)(arg1 * arg2 * arg3))(2, 2, 2) == 64);
BOOST_TEST((arg1)(arg1)(8) == 8);
BOOST_TEST((arg1)(arg1 + arg2)(8, 9) == 17);
BOOST_TEST((arg1 + arg2)(arg1, arg1)(8) == 16);
return boost::report_errors();
}