File indexing completed on 2024-11-15 09:22:45
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef BOOST_PHOENIX_CORE_VALUE_HPP
0009 #define BOOST_PHOENIX_CORE_VALUE_HPP
0010
0011 #include <boost/phoenix/core/limits.hpp>
0012 #include <boost/phoenix/core/actor.hpp>
0013 #include <boost/phoenix/core/as_actor.hpp>
0014 #include <boost/phoenix/core/terminal.hpp>
0015 #include <boost/phoenix/core/is_value.hpp>
0016 #include <boost/utility/result_of.hpp>
0017
0018 namespace boost { namespace phoenix
0019 {
0020
0021
0022
0023
0024
0025
0026
0027
0028 namespace expression
0029 {
0030 template <typename T>
0031 struct value
0032 : expression::terminal<T>
0033 {
0034 typedef
0035 typename expression::terminal<T>::type
0036 type;
0037
0038
0039
0040
0041
0042
0043
0044 };
0045 }
0046
0047 template <typename T>
0048 inline
0049 typename expression::value<T>::type const
0050 val(T t)
0051 {
0052 return expression::value<T>::make(t);
0053 }
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067 template<typename Expr>
0068 struct is_custom_terminal<actor<Expr> >
0069 : mpl::true_
0070 {};
0071
0072
0073 template<typename Expr>
0074 struct custom_terminal<actor<Expr> >
0075 {
0076 template <typename Sig>
0077 struct result;
0078
0079 template <typename This, typename Actor, typename Context>
0080 struct result<This(Actor, Context)>
0081 : boost::remove_const<
0082 typename boost::remove_reference<
0083 typename evaluator::impl<Actor, Context, proto::empty_env>::result_type
0084 >::type
0085 >
0086 {};
0087
0088 template <typename Context>
0089 typename result<custom_terminal(actor<Expr> const &, Context &)>::type
0090 operator()(actor<Expr> const & expr, Context & ctx) const
0091 {
0092 typedef typename result<custom_terminal(actor<Expr> const &, Context &)>::type result_type;
0093 result_type r = boost::phoenix::eval(expr, ctx);
0094
0095 return r;
0096 }
0097 };
0098
0099 namespace meta
0100 {
0101 template<typename T>
0102 struct const_ref
0103 : add_reference<typename add_const<T>::type>
0104 {};
0105
0106 template<typename T>
0107 struct argument_type
0108 : mpl::eval_if_c<
0109 is_function<typename remove_pointer<T>::type>::value
0110 , mpl::identity<T>
0111 , const_ref<T>
0112 >
0113 {
0114 typedef T type;
0115 };
0116
0117 template <typename T>
0118 struct decay
0119 {
0120 typedef T type;
0121 };
0122 template <typename T, int N>
0123 struct decay<T[N]> : decay<T const *> {};
0124 }
0125
0126 template <typename T>
0127 struct as_actor<T, mpl::false_>
0128 {
0129 typedef typename expression::value<typename meta::decay<T>::type >::type type;
0130
0131 static type
0132 convert(typename meta::argument_type<typename meta::decay<T>::type>::type t)
0133 {
0134 return expression::value<typename meta::decay<T>::type >::make(t);
0135 }
0136 };
0137 }}
0138
0139 #endif