Chris@16: /////////////////////////////////////////////////////////////////////////////// Chris@16: /// \file pop_front.hpp Chris@16: /// Proto callables Fusion pop_front Chris@16: // Chris@16: // Copyright 2010 Eric Niebler. Distributed under the Boost Chris@16: // Software License, Version 1.0. (See accompanying file Chris@16: // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) Chris@16: Chris@16: #ifndef BOOST_PROTO_FUNCTIONAL_FUSION_POP_FRONT_HPP_EAN_11_27_2010 Chris@16: #define BOOST_PROTO_FUNCTIONAL_FUSION_POP_FRONT_HPP_EAN_11_27_2010 Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: namespace boost { namespace proto { namespace functional Chris@16: { Chris@16: /// \brief A PolymorphicFunctionObject type that invokes the Chris@16: /// \c fusion::pop_front() algorithm on its argument. Chris@16: /// Chris@16: /// A PolymorphicFunctionObject type that invokes the Chris@16: /// \c fusion::pop_front() algorithm on its argument. This is Chris@16: /// useful for defining a CallableTransform like \c pop_front(_) Chris@16: /// which removes the first child from a Proto expression node. Chris@16: /// Such a transform might be used as the first argument to the Chris@16: /// \c proto::fold\<\> transform; that is, fold all but Chris@16: /// the first child. Chris@16: struct pop_front Chris@16: { Chris@16: BOOST_PROTO_CALLABLE() Chris@16: Chris@16: template Chris@16: struct result; Chris@16: Chris@16: template Chris@16: struct result Chris@16: : result Chris@16: {}; Chris@16: Chris@16: template Chris@16: struct result Chris@16: : fusion::result_of::pop_front Chris@16: {}; Chris@16: Chris@16: template Chris@16: typename fusion::result_of::pop_front::type Chris@16: operator ()(Seq &seq) const Chris@16: { Chris@16: // Work around a const-correctness issue in Fusion Chris@16: typedef typename fusion::result_of::pop_front::type result_type; Chris@16: return result_type(fusion::next(fusion::begin(seq)), fusion::end(seq)); Chris@16: } Chris@16: Chris@16: template Chris@16: typename fusion::result_of::pop_front::type Chris@16: operator ()(Seq const &seq) const Chris@16: { Chris@16: return fusion::pop_front(seq); Chris@16: } Chris@16: }; Chris@16: }}} Chris@16: Chris@16: #endif