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:
38
test/core/function_composition.cpp
Normal file
38
test/core/function_composition.cpp
Normal 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();
|
||||
}
|
||||
Reference in New Issue
Block a user