File indexing completed on 2024-11-16 09:26:08
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef BOOST_PHOENIX_OBJECT_DYNAMIC_CAST_HPP
0009 #define BOOST_PHOENIX_OBJECT_DYNAMIC_CAST_HPP
0010
0011 #include <boost/phoenix/core/limits.hpp>
0012 #include <boost/phoenix/core/call.hpp>
0013 #include <boost/phoenix/core/expression.hpp>
0014 #include <boost/phoenix/core/meta_grammar.hpp>
0015 #include <boost/phoenix/object/detail/target.hpp>
0016 #include <boost/proto/transform/lazy.hpp>
0017
0018 BOOST_PHOENIX_DEFINE_EXPRESSION(
0019 (boost)(phoenix)(dynamic_cast_)
0020 , (proto::terminal<detail::target<proto::_> >)
0021 (meta_grammar)
0022 )
0023
0024 namespace boost { namespace phoenix
0025 {
0026 struct dynamic_cast_eval
0027 {
0028 template <typename Sig>
0029 struct result;
0030
0031 template <typename This, typename Target, typename Source, typename Context>
0032 struct result<This(Target, Source, Context)>
0033 : detail::result_of::target<Target>
0034 {};
0035
0036 template <typename Target, typename Source, typename Context>
0037 typename detail::result_of::target<Target>::type
0038 operator()(Target, Source const& u, Context const& ctx) const
0039 {
0040 return
0041 dynamic_cast<
0042 typename detail::result_of::target<Target>::type
0043 >(boost::phoenix::eval(u, ctx));
0044 }
0045 };
0046
0047 template <typename Dummy>
0048 struct default_actions::when<rule::dynamic_cast_, Dummy>
0049 : call<dynamic_cast_eval, Dummy>
0050 {};
0051
0052 template <typename T, typename U>
0053 inline
0054 typename expression::dynamic_cast_<detail::target<T>, U>::type const
0055 dynamic_cast_(U const& u)
0056 {
0057 return
0058 expression::
0059 dynamic_cast_<detail::target<T>, U>::
0060 make(detail::target<T>(), u);
0061 }
0062 }}
0063
0064 #endif