Imported Upstream version 1.51.0
[platform/upstream/boost.git] / boost / spirit / home / phoenix / object / dynamic_cast.hpp
1 /*=============================================================================
2     Copyright (c) 2001-2007 Joel de Guzman
3
4     Distributed under the Boost Software License, Version 1.0. (See accompanying 
5     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 ==============================================================================*/
7 #ifndef PHOENIX_OBJECT_DYNAMIC_CAST_HPP
8 #define PHOENIX_OBJECT_DYNAMIC_CAST_HPP
9
10 #include <boost/spirit/home/phoenix/core/compose.hpp>
11
12 namespace boost { namespace phoenix
13 {
14     namespace impl
15     {
16         template <typename T>
17         struct dynamic_cast_eval
18         {
19             template <typename Env, typename U>
20             struct result
21             {
22                 typedef T type;
23             };
24
25             template <typename RT, typename Env, typename U>
26             static RT
27             eval(Env const& env, U& obj)
28             {
29                 return dynamic_cast<RT>(obj.eval(env));
30             }
31         };
32     }
33
34     template <typename T, typename U>
35     inline actor<typename as_composite<impl::dynamic_cast_eval<T>, U>::type>
36     dynamic_cast_(U const& obj)
37     {
38         return compose<impl::dynamic_cast_eval<T> >(obj);
39     }
40 }}
41
42 #endif