]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /*============================================================================= |
2 | Copyright (c) 2001-2007 Joel de Guzman | |
3 | Copyright (c) 2014 John Fletcher | |
4 | ||
5 | Distributed under the Boost Software License, Version 1.0. (See accompanying | |
6 | file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
7 | ==============================================================================*/ | |
8 | #include <iostream> | |
9 | #include <cmath> | |
10 | #include <algorithm> | |
11 | #include <vector> | |
12 | ||
13 | #include <typeinfo> | |
14 | ||
15 | // Test of workaround for MSVC 12 and 14 | |
16 | #include <boost/config.hpp> | |
17 | #if defined(BOOST_MSVC) && (BOOST_MSVC >= 1700) | |
18 | #define BOOST_RESULT_OF_USE_TR1 | |
19 | #endif | |
20 | #include <boost/detail/lightweight_test.hpp> | |
21 | #include <boost/phoenix/core.hpp> | |
22 | #include <boost/phoenix/operator.hpp> | |
23 | #include <boost/phoenix/function.hpp> | |
24 | //#include <boost/phoenix/bind.hpp> | |
25 | #include <boost/phoenix/scope.hpp> | |
26 | ||
27 | struct zzz {}; | |
28 | ||
29 | int | |
30 | main() | |
31 | { | |
32 | using boost::phoenix::lambda; | |
33 | using boost::phoenix::let; | |
34 | using boost::phoenix::ref; | |
35 | using boost::phoenix::val; | |
36 | using boost::phoenix::arg_names::_1; | |
37 | using boost::phoenix::arg_names::_2; | |
38 | using boost::phoenix::arg_names::_3; | |
39 | using boost::phoenix::local_names::_a; | |
40 | //using boost::phoenix::local_names::_b; | |
41 | // using boost::phoenix::placeholders::arg1; | |
42 | ||
43 | /* | |
44 | { | |
45 | int x = 1; | |
46 | long x2 = 2; | |
47 | short x3 = 3; | |
48 | char const* y = "hello"; | |
49 | zzz z; | |
50 | ||
51 | BOOST_TEST(lambda[_1](x)(y) == y); | |
52 | BOOST_TEST(lambda(_a = _1)[_a](x)(y) == x); | |
53 | BOOST_TEST(lambda(_a = _1)[lambda[_a]](x)(y)(z) == x); | |
54 | BOOST_TEST(lambda(_a = _1)[lambda[_a + _1]](x)(y)(x) == 2); | |
55 | BOOST_TEST(lambda(_a = _1)[lambda(_b = _1)[_a + _b + _1]](x)(x2)(x3) == 6); | |
56 | } | |
57 | */ | |
58 | /*{ | |
59 | int x = 1, y = 10; | |
60 | BOOST_TEST( | |
61 | (_1 + lambda(_a = _1)[_a + _1 + 2])(x)(y) == 1+1+10+2 | |
62 | ); | |
63 | } | |
64 | */ | |
65 | { | |
66 | int x = 1, y = 10; | |
67 | #if defined(BOOST_MSVC) && (BOOST_MSVC >= 1700) | |
68 | int z; | |
69 | BOOST_TEST( | |
70 | ( | |
71 | _1 + | |
72 | lambda(_a = _1) | |
73 | [ | |
74 | _a + lambda[_a + 2] | |
75 | ] | |
76 | ) | |
77 | (x)()(x) == 1+1+1+2 | |
78 | ); | |
79 | #else | |
80 | BOOST_TEST( | |
81 | ( | |
82 | _1 + | |
83 | lambda(_a = _1) | |
84 | [ | |
85 | _a + lambda[_a + 2] | |
86 | ] | |
87 | ) | |
88 | (x)(y)(y) == 1+1+1+2 | |
89 | ); | |
90 | #endif | |
91 | } | |
92 | ||
93 | return boost::report_errors(); | |
94 | } |