1
/*==============================================================================
2
Copyright (c) 2001-2010 Joel de Guzman
3
Copyright (c) 2010 Thomas Heller
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
#ifndef BOOST_PHOENIX_OBJECT_DYNAMIC_CAST_HPP
9
#define BOOST_PHOENIX_OBJECT_DYNAMIC_CAST_HPP
11
#include <boost/phoenix/core/limits.hpp>
12
#include <boost/phoenix/core/call.hpp>
13
#include <boost/phoenix/core/expression.hpp>
14
#include <boost/phoenix/core/meta_grammar.hpp>
15
#include <boost/phoenix/object/detail/target.hpp>
16
#include <boost/proto/transform/lazy.hpp>
18
BOOST_PHOENIX_DEFINE_EXPRESSION(
19
(boost)(phoenix)(dynamic_cast_)
20
, (proto::terminal<detail::target<proto::_> >)
24
namespace boost { namespace phoenix
26
struct dynamic_cast_eval
28
template <typename Sig>
31
template <typename This, typename Target, typename Source, typename Context>
32
struct result<This(Target, Source, Context)>
33
: detail::result_of::target<Target>
36
template <typename Target, typename Source, typename Context>
37
typename detail::result_of::target<Target>::type
38
operator()(Target, Source const& u, Context const& ctx) const
42
typename detail::result_of::target<Target>::type
43
>(boost::phoenix::eval(u, ctx));
47
template <typename Dummy>
48
struct default_actions::when<rule::dynamic_cast_, Dummy>
49
: call<dynamic_cast_eval, Dummy>
52
template <typename T, typename U>
54
typename expression::dynamic_cast_<detail::target<T>, U>::type const
55
dynamic_cast_(U const& u)
59
dynamic_cast_<detail::target<T>, U>::
60
make(detail::target<T>(), u);