/*============================================================================= Copyright (c) 2001-2007 Joel de Guzman Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ #ifndef PHOENIX_CORE_VALUE_HPP #define PHOENIX_CORE_VALUE_HPP #include #include #include #include #include #include #include #include #include #include #include #include #include namespace boost { namespace phoenix { namespace meta { template struct const_ref : add_reference::type> {}; template struct argument_type : mpl::eval_if< is_function::type>, mpl::identity, const_ref > { typedef T type; }; } template struct value { BOOST_STATIC_ASSERT( mpl::not_ >::value != 0); typedef mpl::false_ no_nullary; template struct result { typedef T type; }; value() : val() {} value(T const& arg) : val(arg) {} template T const& eval(Env const&) const { return val; } T val; }; template struct actor_value { typedef typename Actor::no_nullary no_nullary; template struct result { typedef typename remove_reference< typename eval_result::type >::type type; }; actor_value(Actor const& actor) : actor(actor) {} template typename result::type eval(Env const& env) const { return actor.eval(env); } Actor actor; }; template inline typename as_actor::type val(T const& v) { return as_actor::convert(v); } template inline actor > val(actor const& actor) { return actor_value(actor); } template struct as_actor_base { typedef value type; static value convert(typename meta::argument_type::type x) { return value(x); } }; // Sometimes it is necessary to auto-convert references to // a value. This happens when we are re-currying. This // cannot happen through the standard public actor interfaces. template struct as_actor_base { typedef value type; static value convert(T& x) { return value(x); } }; template struct as_actor_base { typedef value type; static value convert(T const x[N]) { return value(x); } }; }} #endif