Chris@16
|
1 /*==============================================================================
|
Chris@16
|
2 Copyright (c) 2005-2007 Dan Marsden
|
Chris@16
|
3 Copyright (c) 2005-2010 Joel de Guzman
|
Chris@16
|
4 Copyright (c) 2010 Thomas Heller
|
Chris@16
|
5
|
Chris@16
|
6 Distributed under the Boost Software License, Version 1.0. (See accompanying
|
Chris@16
|
7 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
8 ==============================================================================*/
|
Chris@16
|
9 #ifndef BOOST_PHOENIX_STATEMENT_THROW_HPP
|
Chris@16
|
10 #define BOOST_PHOENIX_STATEMENT_THROW_HPP
|
Chris@16
|
11
|
Chris@16
|
12 #include <boost/phoenix/core/limits.hpp>
|
Chris@16
|
13 #include <boost/phoenix/core/actor.hpp>
|
Chris@16
|
14 #include <boost/phoenix/core/call.hpp>
|
Chris@16
|
15 #include <boost/phoenix/core/meta_grammar.hpp>
|
Chris@16
|
16 #include <boost/phoenix/core/expression.hpp>
|
Chris@16
|
17 #include <boost/phoenix/core/terminal.hpp>
|
Chris@16
|
18 #include <boost/phoenix/core/value.hpp>
|
Chris@16
|
19
|
Chris@16
|
20 namespace boost { namespace phoenix
|
Chris@16
|
21 {
|
Chris@16
|
22 namespace tag
|
Chris@16
|
23 {
|
Chris@16
|
24 struct throw_ {};
|
Chris@16
|
25 }
|
Chris@16
|
26
|
Chris@16
|
27 namespace expression
|
Chris@16
|
28 {
|
Chris@16
|
29 template <typename A>
|
Chris@16
|
30 struct throw_
|
Chris@16
|
31 : expr<tag::throw_, A>
|
Chris@16
|
32 {};
|
Chris@16
|
33 }
|
Chris@16
|
34
|
Chris@16
|
35 namespace rule
|
Chris@16
|
36 {
|
Chris@16
|
37 struct throw_
|
Chris@16
|
38 : expression::throw_<meta_grammar>
|
Chris@16
|
39 {};
|
Chris@16
|
40 }
|
Chris@16
|
41
|
Chris@16
|
42 template <typename Dummy>
|
Chris@16
|
43 struct meta_grammar::case_<tag::throw_, Dummy>
|
Chris@16
|
44 : enable_rule<rule::throw_, Dummy>
|
Chris@16
|
45 {};
|
Chris@16
|
46
|
Chris@16
|
47 struct throw_eval
|
Chris@16
|
48 {
|
Chris@16
|
49 typedef void result_type;
|
Chris@16
|
50
|
Chris@16
|
51 template <typename ThrowExpr, typename Context>
|
Chris@16
|
52 result_type
|
Chris@16
|
53 operator()(ThrowExpr const& throw_expr, Context const & ctx) const
|
Chris@16
|
54 {
|
Chris@16
|
55 throw boost::phoenix::eval(throw_expr, ctx);
|
Chris@16
|
56 }
|
Chris@16
|
57 };
|
Chris@16
|
58
|
Chris@16
|
59 template <typename Dummy>
|
Chris@16
|
60 struct default_actions::when<rule::throw_, Dummy>
|
Chris@16
|
61 : call<throw_eval>
|
Chris@16
|
62 {};
|
Chris@16
|
63
|
Chris@16
|
64 template <typename ThrowExpr>
|
Chris@16
|
65 inline
|
Chris@16
|
66 typename expression::throw_<ThrowExpr>::type const
|
Chris@16
|
67 throw_(ThrowExpr const& throw_expr)
|
Chris@16
|
68 {
|
Chris@16
|
69 return expression::throw_<ThrowExpr>::make(throw_expr);
|
Chris@16
|
70 }
|
Chris@16
|
71
|
Chris@16
|
72 namespace detail
|
Chris@16
|
73 {
|
Chris@16
|
74 struct rethrow {};
|
Chris@16
|
75 }
|
Chris@16
|
76
|
Chris@16
|
77 namespace expression
|
Chris@16
|
78 {
|
Chris@16
|
79 struct rethrow
|
Chris@16
|
80 : expression::value<detail::rethrow>
|
Chris@16
|
81 {};
|
Chris@16
|
82 }
|
Chris@16
|
83
|
Chris@16
|
84 template<typename Dummy>
|
Chris@16
|
85 struct is_custom_terminal<detail::rethrow, Dummy>
|
Chris@16
|
86 : mpl::true_
|
Chris@16
|
87 {};
|
Chris@16
|
88
|
Chris@16
|
89 template<typename Dummy>
|
Chris@16
|
90 struct custom_terminal<detail::rethrow, Dummy>
|
Chris@16
|
91 {
|
Chris@16
|
92 typedef void result_type;
|
Chris@101
|
93 //#ifndef BOOST_PHOENIX_NO_SPECIALIZE_CUSTOM_TERMINAL
|
Chris@101
|
94 typedef void _is_throw_custom_terminal; // fix for #7730
|
Chris@101
|
95 //#endif
|
Chris@16
|
96
|
Chris@16
|
97 template <typename Context>
|
Chris@16
|
98 void operator()(detail::rethrow, Context &) const
|
Chris@16
|
99 {
|
Chris@16
|
100 throw;
|
Chris@16
|
101 }
|
Chris@16
|
102 };
|
Chris@16
|
103
|
Chris@16
|
104 inline
|
Chris@16
|
105 expression::rethrow::type const
|
Chris@16
|
106 throw_()
|
Chris@16
|
107 {
|
Chris@16
|
108 return expression::rethrow::make(detail::rethrow());
|
Chris@16
|
109 }
|
Chris@16
|
110
|
Chris@16
|
111 }}
|
Chris@16
|
112
|
Chris@16
|
113 #endif
|