]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/spirit/classic/phoenix/example/fundamental/closures.cpp
1 /*=============================================================================
3 Copyright (c) 2001-2003 Joel de Guzman
5 Use, modification and distribution is subject to the Boost Software
6 License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
7 http://www.boost.org/LICENSE_1_0.txt)
8 ==============================================================================*/
14 #define PHOENIX_LIMIT 15
15 #include <boost/spirit/include/phoenix1_operators.hpp>
16 #include <boost/spirit/include/phoenix1_primitives.hpp>
17 #include <boost/spirit/include/phoenix1_composite.hpp>
18 #include <boost/spirit/include/phoenix1_special_ops.hpp>
19 #include <boost/spirit/include/phoenix1_statements.hpp>
20 #include <boost/spirit/include/phoenix1_functions.hpp>
21 #include <boost/spirit/include/phoenix1_closures.hpp>
23 //////////////////////////////////
24 using namespace phoenix
;
26 //////////////////////////////////
30 struct my_closure
: closure
<int, std::string
, double> {
39 { // First stack frame
40 closure_frame
<my_closure::self_t
> frame(clos
);
43 (clos
.real
= clos
.num
/ 56.5)();
44 (clos
.message
= "Hello " + std::string("World "))();
46 { // Second stack frame
47 closure_frame
<my_closure::self_t
> frame(clos
);
49 (clos
.message
= "Abracadabra ")();
50 (clos
.real
= clos
.num
* 1e30
)();
52 { // Third stack frame
53 tuple
<int, char const*, double> init(-1, "Direct Init ", 3.14);
54 closure_frame
<my_closure::self_t
> frame(clos
, init
);
56 (std::cout
<< clos
.message
<< clos
.num
<< ", " << clos
.real
<< '\n')();
59 (std::cout
<< clos
.message
<< clos
.num
<< ", " << clos
.real
<< '\n')();
62 (std::cout
<< clos
.message
<< clos
.num
<< ", " << clos
.real
<< '\n')();