1 /*=============================================================================
2 Copyright (c) 2001-2007 Joel de Guzman
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_CORE_VALUE_HPP
8 #define PHOENIX_CORE_VALUE_HPP
10 #include <boost/spirit/home/phoenix/core/actor.hpp>
11 #include <boost/spirit/home/phoenix/core/as_actor.hpp>
12 #include <boost/static_assert.hpp>
14 #include <boost/type_traits/is_reference.hpp>
15 #include <boost/type_traits/remove_reference.hpp>
16 #include <boost/type_traits/is_pointer.hpp>
17 #include <boost/type_traits/add_const.hpp>
18 #include <boost/type_traits/add_reference.hpp>
19 #include <boost/type_traits/remove_pointer.hpp>
20 #include <boost/type_traits/is_function.hpp>
22 #include <boost/mpl/bool.hpp>
23 #include <boost/mpl/eval_if.hpp>
24 #include <boost/mpl/identity.hpp>
26 namespace boost { namespace phoenix
32 : add_reference<typename add_const<T>::type>
38 is_function<typename remove_pointer<T>::type>,
50 mpl::not_<is_reference<T> >::value != 0);
52 typedef mpl::false_ no_nullary;
54 template <typename Env>
66 template <typename Env>
68 eval(Env const&) const
76 template <typename Actor>
79 typedef typename Actor::no_nullary no_nullary;
81 template <typename Env>
86 typename eval_result<Actor, Env>::type
91 actor_value(Actor const& actor)
94 template <typename Env>
95 typename result<Env>::type
96 eval(Env const& env) const
98 return actor.eval(env);
104 template <typename T>
105 inline typename as_actor<T>::type
108 return as_actor<T>::convert(v);
111 template <typename Derived>
112 inline actor<actor_value<Derived> >
113 val(actor<Derived> const& actor)
115 return actor_value<Derived>(actor);
118 template <typename T>
121 typedef value<T> type;
124 convert(typename meta::argument_type<T>::type x)
130 // Sometimes it is necessary to auto-convert references to
131 // a value<T>. This happens when we are re-currying. This
132 // cannot happen through the standard public actor interfaces.
133 template <typename T>
134 struct as_actor_base<T&>
136 typedef value<T> type;
145 template <typename T, int N>
146 struct as_actor_base<T[N]>
148 typedef value<T const*> type;
150 static value<T const*>
151 convert(T const x[N])
153 return value<T const*>(x);