1 /*============================================================================= 2 Copyright (c) 2001-2013 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 <boost/spirit/home/x3/support/context.hpp> 8 #include <iostream> 9 10 using boost::spirit::x3::make_context; 11 using boost::spirit::x3::get; 12 13 int bb; 14 int cc; 15 16 struct b_ctx; 17 struct c_ctx; 18 19 template <typename Context> a(Context const & context)20void a(Context const& context) 21 { 22 bb = get<b_ctx>(context); 23 cc = get<c_ctx>(context); 24 } 25 26 template <typename Context> b(Context const & context)27void b(Context const& context) 28 { 29 int bi = 123; 30 a(make_context<b_ctx>(bi, context)); 31 } 32 c()33void c() 34 { 35 int ci = 456; 36 b(make_context<c_ctx>(ci)); 37 } 38 test()39void test() 40 { 41 c(); 42 43 // MSVC generates this code: 44 // mov DWORD PTR ?bb@@3HA, 123 45 // mov DWORD PTR ?cc@@3HA, 456 46 // 47 // GCC generates this code: 48 // movl $123, _bb 49 // movl $456, _cc 50 } 51 52