1 [/==============================================================================
2 Copyright (C) 2001-2010 Joel de Guzman
3 Copyright (C) 2001-2005 Dan Marsden
4 Copyright (C) 2001-2010 Thomas Heller
6 Distributed under the Boost Software License, Version 1.0. (See accompanying
7 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 ===============================================================================/]
10 [section Porting from Phoenix 2.0]
12 While reading the current documentation you might have noticed that the
13 [link phoenix.starter_kit Starter Kit] didn't change very much. This is because
14 a lot of effort was put into being compatible with Phoenix 2.0, at least on the
17 That being said, the only major difference is the result type deduction protocol.
18 The everyday Phoenix-User will encounter this change only when writing
19 [link phoenix.reference.modules.function Functions].
21 To make your function implementations Phoenix compliant again change from
22 the old Phoenix result type deduction protocol to the new (standard compliant)
23 result type deduction protocol:
26 [[Phoenix 2.0] [Phoenix 3.0] [Notes]]
31 template <typename Arg>
37 template <typename Arg>
38 bool operator()(Arg arg) const
44 boost::phoenix::function<is_odd_impl> is_odd = is_odd_impl();
49 typedef bool result_type;
51 template <typename Arg>
52 bool operator()(Arg arg) const
58 boost::phoenix::function<is_odd_impl> is_odd = is_odd_impl();
61 The result_of protocol is particularly easy when you implement a monomorphic
62 function (return type not dependent on the arguments). You then just need a
63 single nested return_type typedef.
70 template <typename Arg1, typename Arg2>
76 template <typename Arg1, typename Arg2>
77 Arg1 operator()(Arg1 arg1, Arg2 arg2) const
83 boost::phoenix::function<add_impl> add = add_impl();
88 template <typename Sig>
91 template <typename This, typename Arg1, typename Arg2>
92 struct result<This(Arg1, Arg2)>
93 : boost::remove_reference<Arg1> {};
95 template <typename Arg1, typename Arg2>
96 typename boost::remove_reference<Arg1>::type
97 operator()(Arg1 arg1, Arg2 arg2) const
103 boost::phoenix::function<add_impl> add = add_impl();
105 [__alert__ When dealing with polymorphic functions the template arguments can
106 be any type including cv-qualifiers and references. For that reason, the calculated
107 result type need to remove the reference whenever appropriate!]
111 [blurb __tip__ There is no general guideline for porting code which relies on the
112 internals of Phoenix 2.0. If you plan on porting your Phoenix 2.0 extensions
113 please refer to the next sections.]