pop_back.hpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. ///////////////////////////////////////////////////////////////////////////////
  2. /// \file pop_back.hpp
  3. /// Proto callables Fusion pop_back
  4. //
  5. // Copyright 2010 Eric Niebler. Distributed under the Boost
  6. // Software License, Version 1.0. (See accompanying file
  7. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  8. #ifndef BOOST_PROTO_FUNCTIONAL_FUSION_POP_BACK_HPP_EAN_11_27_2010
  9. #define BOOST_PROTO_FUNCTIONAL_FUSION_POP_BACK_HPP_EAN_11_27_2010
  10. #include <boost/fusion/include/begin.hpp>
  11. #include <boost/fusion/include/end.hpp>
  12. #include <boost/fusion/include/prior.hpp>
  13. #include <boost/fusion/include/pop_back.hpp>
  14. #include <boost/proto/proto_fwd.hpp>
  15. namespace boost { namespace proto { namespace functional
  16. {
  17. /// \brief A PolymorphicFunctionObject type that invokes the
  18. /// \c fusion::pop_back() algorithm on its argument.
  19. ///
  20. /// A PolymorphicFunctionObject type that invokes the
  21. /// \c fusion::pop_back() algorithm on its argument.
  22. struct pop_back
  23. {
  24. BOOST_PROTO_CALLABLE()
  25. template<typename Sig>
  26. struct result;
  27. template<typename This, typename Seq>
  28. struct result<This(Seq)>
  29. : result<This(Seq const &)>
  30. {};
  31. template<typename This, typename Seq>
  32. struct result<This(Seq &)>
  33. : fusion::result_of::pop_back<Seq>
  34. {};
  35. template<typename Seq>
  36. typename fusion::result_of::pop_back<Seq>::type
  37. operator ()(Seq &seq) const
  38. {
  39. // Work around a const-correctness issue in Fusion
  40. typedef typename fusion::result_of::pop_back<Seq>::type result_type;
  41. return result_type(fusion::begin(seq), fusion::prior(fusion::end(seq)));
  42. }
  43. template<typename Seq>
  44. typename fusion::result_of::pop_back<Seq const>::type
  45. operator ()(Seq const &seq) const
  46. {
  47. return fusion::pop_back(seq);
  48. }
  49. };
  50. }}}
  51. #endif