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