/////////////////////////////////////////////////////////////////////////////// /// \file arg.hpp /// Contains definition of the argN transforms. // // 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_TRANSFORM_ARG_HPP_EAN_11_01_2007 #define BOOST_PROTO_TRANSFORM_ARG_HPP_EAN_11_01_2007 #include #include #include #include namespace boost { namespace proto { namespace transform { /// \brief A PrimitiveTransform that returns the current expression /// unmodified struct expr : proto::callable { template struct result; template struct result { typedef Expr type; }; /// \param expr_ The current expression. /// \return \c expr_ /// \throw nothrow template Expr const & operator ()(Expr const &expr_, State const &, Visitor &) const { return expr_; } }; /// \brief A PrimitiveTransform that returns the current state /// unmodified struct state : proto::callable { template struct result; template struct result { typedef State type; }; /// \param state_ The current state. /// \return \c state_ /// \throw nothrow template State const & operator ()(Expr const &, State const &state_, Visitor &) const { return state_; } }; /// \brief A PrimitiveTransform that returns the current visitor /// unmodified struct visitor : proto::callable { template struct result; template struct result { typedef Visitor type; }; /// \param visitor_ The current visitor /// \return \c visitor_ /// \throw nothrow template Visitor & operator ()(Expr const &, State const &, Visitor &visitor_) const { return visitor_; } }; /// \brief A PrimitiveTransform that returns I-th child of the current /// expression. template struct arg_c : proto::callable { template struct result; template struct result { typedef typename proto::result_of::arg_c::type type; }; /// \param expr The current expression. /// \return proto::arg_c\(expr) /// \throw nothrow template typename proto::result_of::arg_c::const_reference operator ()(Expr const &expr, State const &, Visitor &) const { return proto::arg_c(expr); } }; /// \brief A unary CallableTransform that wraps its argument /// in a \c boost::reference_wrapper\<\>. struct _ref : proto::callable { template struct result; template struct result { typedef boost::reference_wrapper type; }; template struct result { typedef boost::reference_wrapper type; }; /// \param t The object to wrap /// \return boost::ref(t) /// \throw nothrow template boost::reference_wrapper operator ()(T &t) const { return boost::reference_wrapper(t); } /// \overload /// template boost::reference_wrapper operator ()(T const &t) const { return boost::reference_wrapper(t); } }; } /// \brief A PrimitiveTransform that returns I-th child of the current /// expression. template struct _arg_c : transform::arg_c {}; /// INTERNAL ONLY /// template<> struct is_callable : mpl::true_ {}; /// INTERNAL ONLY /// template<> struct is_callable : mpl::true_ {}; /// INTERNAL ONLY /// template<> struct is_callable : mpl::true_ {}; /// INTERNAL ONLY /// template struct is_callable > : mpl::true_ {}; /// INTERNAL ONLY /// template struct is_callable<_arg_c > : mpl::true_ {}; /// INTERNAL ONLY /// template<> struct is_callable : mpl::true_ {}; }} #endif