rbegin.hpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. ///////////////////////////////////////////////////////////////////////////////
  2. /// \file rbegin.hpp
  3. /// Proto callables for boost::rbegin()
  4. //
  5. // Copyright 2012 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_RANGE_RBEGIN_HPP_EAN_27_08_2012
  9. #define BOOST_PROTO_FUNCTIONAL_RANGE_RBEGIN_HPP_EAN_27_08_2012
  10. #include <boost/range/rbegin.hpp>
  11. #include <boost/proto/proto_fwd.hpp>
  12. namespace boost { namespace proto { namespace functional
  13. {
  14. // A PolymorphicFunctionObject that wraps boost::rbegin()
  15. struct rbegin
  16. {
  17. BOOST_PROTO_CALLABLE()
  18. template<typename Sig>
  19. struct result;
  20. template<typename This, typename Rng>
  21. struct result<This(Rng)>
  22. : boost::range_reverse_iterator<Rng const>
  23. {};
  24. template<typename This, typename Rng>
  25. struct result<This(Rng &)>
  26. : boost::range_reverse_iterator<Rng>
  27. {};
  28. template<typename Rng>
  29. typename boost::range_reverse_iterator<Rng>::type operator()(Rng &rng) const
  30. {
  31. return boost::rbegin(rng);
  32. }
  33. template<typename Rng>
  34. typename boost::range_reverse_iterator<Rng const>::type operator()(Rng const &rng) const
  35. {
  36. return boost::rbegin(rng);
  37. }
  38. };
  39. }}}
  40. #endif