]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/phoenix/test/bind/bind_function_tests.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / phoenix / test / bind / bind_function_tests.cpp
1 /*=============================================================================
2 Copyright (c) 2001-2007 Joel de Guzman
3
4 Distributed under the Boost Software License, Version 1.0. (See accompanying
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 ==============================================================================*/
7 #include <iostream>
8 #include <cmath>
9 #include <boost/detail/lightweight_test.hpp>
10 #include <boost/phoenix/core.hpp>
11 #include <boost/phoenix/bind.hpp>
12
13 namespace test
14 {
15 void
16 test()
17 {
18 std::cout << "Test binding functions...\n";
19 }
20
21 int
22 negate(int n)
23 {
24 return -n;
25 }
26
27 int
28 plus(int a, int b)
29 {
30 return a + b;
31 }
32
33 int
34 plus4(int a, int b, int c, int d)
35 {
36 return a + b + c + d;
37 }
38 }
39
40 int
41 main()
42 {
43 using boost::phoenix::bind;
44 using boost::phoenix::arg_names::arg1;
45 using boost::phoenix::arg_names::arg2;
46
47 int a = 123;
48 int b = 256;
49
50 bind(test::test)();
51 BOOST_TEST(bind(test::negate, arg1)(a) == -a);
52 BOOST_TEST(bind(test::plus, arg1, arg2)(a, b) == a+b);
53 BOOST_TEST(bind(test::plus4, arg1, arg2, 3, 4)(a, b) == a+b+3+4);
54
55 return boost::report_errors();
56 }