Chris@16
|
1 /*=============================================================================
|
Chris@16
|
2 Copyright (c) 2005-2007 Dan Marsden
|
Chris@16
|
3 Copyright (c) 2005-2007 Joel de Guzman
|
Chris@16
|
4
|
Chris@16
|
5 Distributed under the Boost Software License, Version 1.0. (See accompanying
|
Chris@16
|
6 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
7 ==============================================================================*/
|
Chris@16
|
8
|
Chris@16
|
9 #ifndef PHOENIX_STATEMENT_THROW_HPP
|
Chris@16
|
10 #define PHOENIX_STATEMENT_THROW_HPP
|
Chris@16
|
11
|
Chris@16
|
12 #include <boost/spirit/home/phoenix/core/actor.hpp>
|
Chris@16
|
13 #include <boost/spirit/home/phoenix/core/composite.hpp>
|
Chris@16
|
14 #include <boost/spirit/home/phoenix/core/compose.hpp>
|
Chris@16
|
15
|
Chris@16
|
16 #include <boost/mpl/bool.hpp>
|
Chris@16
|
17
|
Chris@16
|
18 namespace boost { namespace phoenix {
|
Chris@16
|
19
|
Chris@16
|
20 struct throw_new_eval
|
Chris@16
|
21 {
|
Chris@16
|
22 template<typename Env, typename ThrowExpr>
|
Chris@16
|
23 struct result
|
Chris@16
|
24 {
|
Chris@16
|
25 typedef void type;
|
Chris@16
|
26 };
|
Chris@16
|
27
|
Chris@16
|
28 template<typename Rt, typename Env, typename ThrowExpr>
|
Chris@16
|
29 static void
|
Chris@16
|
30 eval(const Env& env, ThrowExpr& throwExpr)
|
Chris@16
|
31 {
|
Chris@16
|
32 throw throwExpr.eval(env);
|
Chris@16
|
33 }
|
Chris@16
|
34 };
|
Chris@16
|
35
|
Chris@16
|
36 struct throw_again_eval
|
Chris@16
|
37 {
|
Chris@16
|
38 typedef mpl::false_ no_nullary;
|
Chris@16
|
39
|
Chris@16
|
40 template<typename Env>
|
Chris@16
|
41 struct result
|
Chris@16
|
42 {
|
Chris@16
|
43 typedef void type;
|
Chris@16
|
44 };
|
Chris@16
|
45
|
Chris@16
|
46 template<typename Env>
|
Chris@16
|
47 void eval(const Env&) const
|
Chris@16
|
48 {
|
Chris@16
|
49 throw;
|
Chris@16
|
50 }
|
Chris@16
|
51 };
|
Chris@16
|
52
|
Chris@16
|
53 inline actor<throw_again_eval> throw_()
|
Chris@16
|
54 {
|
Chris@16
|
55 return throw_again_eval();
|
Chris@16
|
56 }
|
Chris@16
|
57
|
Chris@16
|
58 template<typename Actor>
|
Chris@16
|
59 actor<typename as_composite<throw_new_eval, Actor>::type>
|
Chris@16
|
60 throw_(const Actor& a)
|
Chris@16
|
61 {
|
Chris@16
|
62 return compose<throw_new_eval>(a);
|
Chris@16
|
63 }
|
Chris@16
|
64 }}
|
Chris@16
|
65
|
Chris@16
|
66 #endif
|