#ifndef BOOST_PP_IS_ITERATING /////////////////////////////////////////////////////////////////////////////// /// \file bind.hpp /// Contains definition of the bind<> transform. // // 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_BIND_HPP_EAN_12_02_2007 #define BOOST_PROTO_TRANSFORM_BIND_HPP_EAN_12_02_2007 #include #include #include #include #include #include #include #include namespace boost { namespace proto { namespace transform { /// \brief A PrimitiveTransform that uses make\<\> to build /// a CallableTransform, and then uses call\<\> to apply it. /// /// bind\<\> is useful as a higher-order transform, when the /// transform to be applied depends on the current state of the /// transformation. The invocation of the make\<\> transform /// evaluates any nested transforms, and the resulting type is treated /// as a CallableTransform, which is evaluated with call\<\>. template struct bind : proto::callable { template struct result; template struct result { typedef typename make::template result::type fun; typedef call impl; typedef typename impl::template result::type type; }; /// Build a CallableTransform by applying make\<\> /// and evaluate it with call\<\> /// /// \param expr The current expression /// \param state The current state /// \param visitor An arbitrary visitor /// \return result\::::impl()(expr, state, visitor) template typename result::type operator ()(Expr const &expr, State const &state, Visitor &visitor) const { return typename result::impl()(expr, state, visitor); } }; #define BOOST_PP_ITERATION_PARAMS_1 (3, (0, BOOST_PROTO_MAX_ARITY, )) #include BOOST_PP_ITERATE() } /// INTERNAL ONLY /// template struct is_callable > : mpl::true_ {}; }} #endif #else #define N BOOST_PP_ITERATION() /// \brief A PrimitiveTransform that uses make\<\> to build /// a CallableTransform, and then uses call\<\> to apply it. /// /// bind\<\> is useful as a higher-order transform, when the /// transform to be applied depends on the current state of the /// transformation. The invocation of the make\<\> transform /// evaluates any nested transforms, and the resulting type is treated /// as a CallableTransform, which is evaluated with call\<\>. template struct bind : proto::callable { template struct result; template struct result { typedef typename make::template result::type fun; typedef call impl; typedef typename impl::template result::type type; }; /// Build a CallableTransform by applying make\<\> /// and evaluate it with call\<\> /// /// \param expr The current expression /// \param state The current state /// \param visitor An arbitrary visitor /// \return result\::::impl()(expr, state, visitor) template typename result::type operator ()(Expr const &expr, State const &state, Visitor &visitor) const { return typename result::impl()(expr, state, visitor); } }; #undef N #endif