Imported Upstream version 1.51.0
[platform/upstream/boost.git] / boost / spirit / home / phoenix / statement / detail / catch_composite.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_DETAIL_CATCH_COMPOSITE_HPP
10 #define PHOENIX_STATEMENT_DETAIL_CATCH_COMPOSITE_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 namespace boost { namespace phoenix {
17 namespace detail
18 {
19     struct catch_composite_eval
20     {
21         template<typename Env, typename Actor>
22         struct result :
23             eval_result<typename Actor::eval_type, Env> {};
24
25         template<typename Rt, typename Env, typename Actor>
26         static typename result<Env,Actor>::type
27         eval(const Env& env, Actor& actor)
28         {
29             return actor.eval(env);
30         }
31     };
32
33     template<typename Exception, typename Actor>
34     struct catch_composite :
35         composite<catch_composite_eval, fusion::vector<Actor> >
36     {
37         catch_composite(const Actor& actor)
38             : composite<catch_composite_eval, fusion::vector<Actor> >(actor) { }
39
40         typedef Exception exception_type;
41     };
42
43     template<typename Exception, typename Actor>
44     struct as_catch_actor
45     {
46         typedef catch_composite<
47             Exception,
48             Actor> comp;
49
50         typedef actor<comp> type;
51     };
52
53     template<typename Exception, typename Actor>
54     inline typename as_catch_actor<Exception, Actor>::type
55     catch_actor(const Actor& actor)
56     {
57         return catch_composite<Exception,Actor>(actor);
58     }
59 }
60 }}
61
62 #endif