reverse.hpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /// \file
  2. // Range v3 library
  3. //
  4. // Copyright Eric Niebler 2013-present
  5. // Copyright Gonzalo Brito Gadeschi 2017
  6. //
  7. // Use, modification and distribution is subject to the
  8. // Boost Software License, Version 1.0. (See accompanying
  9. // file LICENSE_1_0.txt or copy at
  10. // http://www.boost.org/LICENSE_1_0.txt)
  11. //
  12. // Project home: https://github.com/ericniebler/range-v3
  13. //
  14. #ifndef RANGES_V3_ACTION_REVERSE_HPP
  15. #define RANGES_V3_ACTION_REVERSE_HPP
  16. #include <range/v3/range_fwd.hpp>
  17. #include <range/v3/action/action.hpp>
  18. #include <range/v3/algorithm/reverse.hpp>
  19. #include <range/v3/iterator/concepts.hpp>
  20. #include <range/v3/range/traits.hpp>
  21. #include <range/v3/utility/static_const.hpp>
  22. #include <range/v3/detail/prologue.hpp>
  23. namespace ranges
  24. {
  25. /// \addtogroup group-actions
  26. /// @{
  27. namespace actions
  28. {
  29. /// Reversed the source range in-place.
  30. struct reverse_fn
  31. {
  32. template(typename Rng)(
  33. requires bidirectional_range<Rng> AND permutable<iterator_t<Rng>>)
  34. Rng operator()(Rng && rng) const
  35. {
  36. ranges::reverse(rng);
  37. return static_cast<Rng &&>(rng);
  38. }
  39. };
  40. /// \relates actions::reverse_fn
  41. /// \sa action_closure
  42. RANGES_INLINE_VARIABLE(action_closure<reverse_fn>, reverse)
  43. } // namespace actions
  44. /// @}
  45. } // namespace ranges
  46. #include <range/v3/detail/epilogue.hpp>
  47. #endif