diff options
author | Kevin Smith <git@kismith.co.uk> | 2013-01-12 18:41:34 (GMT) |
---|---|---|
committer | Swift Review <review@swift.im> | 2013-01-13 10:36:26 (GMT) |
commit | f3bc816af1b0d61452de973963e453bf3b3f95a2 (patch) | |
tree | e895f8afa3580e6cff6f5ad2017d45bf147a17c2 /3rdParty/Boost/src/boost/proto/eval.hpp | |
parent | 188fc285c6555eadd3c9d50ab8a94adcade78d89 (diff) | |
download | swift-f3bc816af1b0d61452de973963e453bf3b3f95a2.zip swift-f3bc816af1b0d61452de973963e453bf3b3f95a2.tar.bz2 |
Adding in the spirit Boost stuff
Change-Id: I4f127ce61667243b64081b0aa309028d5077045f
Diffstat (limited to '3rdParty/Boost/src/boost/proto/eval.hpp')
-rw-r--r-- | 3rdParty/Boost/src/boost/proto/eval.hpp | 140 |
1 files changed, 140 insertions, 0 deletions
diff --git a/3rdParty/Boost/src/boost/proto/eval.hpp b/3rdParty/Boost/src/boost/proto/eval.hpp new file mode 100644 index 0000000..25a91aa --- /dev/null +++ b/3rdParty/Boost/src/boost/proto/eval.hpp @@ -0,0 +1,140 @@ +/////////////////////////////////////////////////////////////////////////////// +/// \file eval.hpp +/// Contains the eval() expression evaluator. +// +// Copyright 2008 Eric Niebler. 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 BOOST_PROTO_EVAL_HPP_EAN_03_29_2007 +#define BOOST_PROTO_EVAL_HPP_EAN_03_29_2007 + +#include <boost/proto/proto_fwd.hpp> // BOOST_PROTO_CALLABLE +#include <boost/type_traits/remove_reference.hpp> + +namespace boost { namespace proto +{ + + namespace result_of + { + /// \brief A metafunction for calculating the return type + /// of \c proto::eval() given a certain \c Expr and \c Context + /// types. + /// + /// \note The types \c Expr and \c Context should not be + /// reference types. They may be cv-qualified, but the + /// cv-qualification on the \c Context parameter is ignored. + template<typename Expr, typename Context> + struct eval + { + typedef typename Context::template eval<Expr>::result_type type; + }; + } + + namespace functional + { + /// \brief A PolymorphicFunctionObject type for + /// evaluating a given Proto expression with a given + /// context. + struct eval + { + BOOST_PROTO_CALLABLE() + + template<typename Sig> + struct result; + + template<typename This, typename Expr, typename Context> + struct result<This(Expr, Context)> + { + typedef + typename proto::result_of::eval< + typename remove_reference<Expr>::type + , typename remove_reference<Context>::type + >::type + type; + }; + + /// \brief Evaluate a given Proto expression with a given + /// context. + /// \param expr The Proto expression to evaluate + /// \param context The context in which the expression should be + /// evaluated. + /// \return <tt>typename Context::template eval<Expr>()(expr, context)</tt> + template<typename Expr, typename Context> + typename proto::result_of::eval<Expr, Context>::type + operator ()(Expr &e, Context &ctx) const + { + return typename Context::template eval<Expr>()(e, ctx); + } + + /// \overload + /// + template<typename Expr, typename Context> + typename proto::result_of::eval<Expr, Context>::type + operator ()(Expr &e, Context const &ctx) const + { + return typename Context::template eval<Expr>()(e, ctx); + } + + /// \overload + /// + template<typename Expr, typename Context> + typename proto::result_of::eval<Expr const, Context>::type + operator ()(Expr const &e, Context &ctx) const + { + return typename Context::template eval<Expr const>()(e, ctx); + } + + /// \overload + /// + template<typename Expr, typename Context> + typename proto::result_of::eval<Expr const, Context>::type + operator ()(Expr const &e, Context const &ctx) const + { + return typename Context::template eval<Expr const>()(e, ctx); + } + }; + } + + /// \brief Evaluate a given Proto expression with a given + /// context. + /// \param expr The Proto expression to evaluate + /// \param context The context in which the expression should be + /// evaluated. + /// \return <tt>typename Context::template eval<Expr>()(expr, context)</tt> + template<typename Expr, typename Context> + typename proto::result_of::eval<Expr, Context>::type + eval(Expr &e, Context &ctx) + { + return typename Context::template eval<Expr>()(e, ctx); + } + + /// \overload + /// + template<typename Expr, typename Context> + typename proto::result_of::eval<Expr, Context>::type + eval(Expr &e, Context const &ctx) + { + return typename Context::template eval<Expr>()(e, ctx); + } + + /// \overload + /// + template<typename Expr, typename Context> + typename proto::result_of::eval<Expr const, Context>::type + eval(Expr const &e, Context &ctx) + { + return typename Context::template eval<Expr const>()(e, ctx); + } + + /// \overload + /// + template<typename Expr, typename Context> + typename proto::result_of::eval<Expr const, Context>::type + eval(Expr const &e, Context const &ctx) + { + return typename Context::template eval<Expr const>()(e, ctx); + } +}} + +#endif |