mirror of
https://github.com/boostorg/phoenix.git
synced 2026-02-15 01:12:09 +00:00
First shot by Thomas Heller
[SVN r62536]
This commit is contained in:
@@ -8,8 +8,15 @@
|
||||
#ifndef PHOENIX_CORE_ACTOR_HPP
|
||||
#define PHOENIX_CORE_ACTOR_HPP
|
||||
|
||||
#include <boost/proto/proto.hpp>
|
||||
#include <boost/fusion/container/vector/vector10.hpp>
|
||||
#include <boost/phoenix/core/actor_result.hpp>
|
||||
#include <boost/phoenix/core/domain.hpp>
|
||||
#include <boost/phoenix/core/meta_grammar.hpp>
|
||||
#include <boost/proto/extends.hpp>
|
||||
#include <boost/proto/debug.hpp>
|
||||
#include <boost/utility/result_of.hpp>
|
||||
|
||||
#include <boost/mpl/void.hpp>
|
||||
namespace boost { namespace phoenix
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
@@ -17,29 +24,70 @@ namespace boost { namespace phoenix
|
||||
// This class is responsible for full function evaluation. Partial
|
||||
// function evaluation involves creating a hierarchy of actor objects.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
template <class Expr>
|
||||
template <typename Expr>
|
||||
struct actor
|
||||
{
|
||||
BOOST_PROTO_BASIC_EXTENDS(Expr, actor<Expr>, phoenix_domain)
|
||||
BOOST_PROTO_EXTENDS_ASSIGN()
|
||||
BOOST_PROTO_EXTENDS_SUBSCRIPT()
|
||||
|
||||
template <class Sig>
|
||||
template <typename Sig>
|
||||
struct result : actor_result<Sig> {};
|
||||
|
||||
typedef actor<Expr> actor_type;
|
||||
|
||||
template <class A0>
|
||||
typename boost::result_of<actor_type(A0 const&)>::type
|
||||
struct dummy {};
|
||||
|
||||
//typename boost::result_of<actor_type()>::type
|
||||
//typename actor_result<actor_type()>::type
|
||||
//typename boost::result_of<eval_grammar(actor_type&, fusion::vector0<>&)>::type
|
||||
void
|
||||
operator()() const
|
||||
{
|
||||
BOOST_PROTO_ASSERT_MATCHES( *this, eval_grammar );
|
||||
fusion::vector0<> args;
|
||||
|
||||
eval(*this, args);
|
||||
//return eval(*this, args);
|
||||
}
|
||||
|
||||
template <typename A0>
|
||||
//typename boost::result_of<actor_type(A0 const&)>::type
|
||||
typename actor_result<actor_type(A0 const&)>::type
|
||||
//typename boost::result_of<eval_grammar(actor_type&, fusion::vector1<A0>&)>::type
|
||||
operator()(A0 const& a0) const
|
||||
{
|
||||
BOOST_PROTO_ASSERT_MATCHES(*this, eval_grammar);
|
||||
fusion::vector<A0 const&> args(a0);
|
||||
fusion::vector1<A0 const&> args(a0);
|
||||
|
||||
return eval(*this, args);
|
||||
}
|
||||
|
||||
template <typename A0, typename A1>
|
||||
//typename boost::result_of<actor_type(A0 const&, A1 const&)>::type
|
||||
typename actor_result<actor_type(A0 const&, A1 const&)>::type
|
||||
//typename boost::result_of<eval_grammar(actor_type&, fusion::vector1<A0, A1>&)>::type
|
||||
operator()(A0 const& a0, A1 const& a1) const
|
||||
{
|
||||
BOOST_PROTO_ASSERT_MATCHES(*this, eval_grammar);
|
||||
fusion::vector2<A0 const&, A1 const &> args(a0, a1);
|
||||
|
||||
std::cout << typeid( eval( *this, args ) ).name() << "\n";
|
||||
|
||||
return eval(*this, args);
|
||||
}
|
||||
|
||||
/*... more...*/
|
||||
};
|
||||
}}
|
||||
}
|
||||
|
||||
template<typename Expr>
|
||||
struct result_of<phoenix::actor<Expr>() >
|
||||
{
|
||||
typedef phoenix::actor<Expr> F;
|
||||
typedef typename F::template result<F()>::type type;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -9,19 +9,32 @@
|
||||
#define PHOENIX_CORE_ACTOR_RESULT_HPP
|
||||
|
||||
#include <boost/phoenix/core/meta_grammar.hpp>
|
||||
#include <boost/fusion/container/vector.hpp>
|
||||
#include <boost/fusion/container/vector/vector10.hpp>
|
||||
#include <boost/utility/result_of.hpp>
|
||||
|
||||
#include <boost/mpl/void.hpp>
|
||||
|
||||
namespace boost { namespace phoenix
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Return type computation
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
template<class Sig>
|
||||
template<typename Sig>
|
||||
struct actor_result;
|
||||
|
||||
template <template Actor, template A0>
|
||||
template <typename Actor>
|
||||
struct actor_result<Actor()>
|
||||
: boost::result_of<eval_grammar(Actor&, fusion::vector0<>&)>
|
||||
{};
|
||||
|
||||
template <typename Actor, typename A0>
|
||||
struct actor_result<Actor(A0)>
|
||||
: boost::result_of<eval_grammar(Actor&, fusion::vector<A0>&)>
|
||||
: boost::result_of<eval_grammar(Actor&, fusion::vector1<A0>&)>
|
||||
{};
|
||||
|
||||
template <typename Actor, typename A0, typename A1>
|
||||
struct actor_result<Actor(A0, A1)>
|
||||
: boost::result_of<eval_grammar(Actor&, fusion::vector2<A0, A1>&)>
|
||||
{};
|
||||
|
||||
/*... more ...*/
|
||||
|
||||
@@ -8,7 +8,10 @@
|
||||
#ifndef PHOENIX_CORE_DOMAIN_HPP
|
||||
#define PHOENIX_CORE_DOMAIN_HPP
|
||||
|
||||
#include <boost/proto/proto.hpp>
|
||||
#include <boost/proto/proto_fwd.hpp>
|
||||
#include <boost/proto/domain.hpp>
|
||||
#include <boost/proto/generate.hpp>
|
||||
#include <boost/proto/matches.hpp>
|
||||
|
||||
namespace boost { namespace phoenix
|
||||
{
|
||||
|
||||
@@ -8,7 +8,14 @@
|
||||
#ifndef PHOENIX_CORE_META_GRAMMAR_HPP
|
||||
#define PHOENIX_CORE_META_GRAMMAR_HPP
|
||||
|
||||
#include <boost/proto/proto.hpp>
|
||||
#include <boost/mpl/deref.hpp>
|
||||
#include <boost/proto/proto_fwd.hpp>
|
||||
#include <boost/proto/matches.hpp>
|
||||
#include <boost/proto/traits.hpp>
|
||||
#include <boost/proto/tags.hpp>
|
||||
#include <boost/proto/transform/arg.hpp>
|
||||
#include <boost/proto/transform/default.hpp>
|
||||
#include <boost/proto/transform/when.hpp>
|
||||
|
||||
namespace boost { namespace phoenix
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user