選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

57 行
1.4KB

  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. namespace ranges
  23. {
  24. /// \addtogroup group-actions
  25. /// @{
  26. namespace actions
  27. {
  28. /// Reversed the source range in-place.
  29. struct reverse_fn
  30. {
  31. private:
  32. friend action_access;
  33. public:
  34. template<typename Rng>
  35. auto operator()(Rng && rng) const -> CPP_ret(Rng)( //
  36. requires bidirectional_range<Rng> && permutable<iterator_t<Rng>>)
  37. {
  38. ranges::reverse(rng);
  39. return static_cast<Rng &&>(rng);
  40. }
  41. };
  42. /// \ingroup group-actions
  43. /// \relates reverse_fn
  44. /// \sa action
  45. RANGES_INLINE_VARIABLE(action<reverse_fn>, reverse)
  46. } // namespace actions
  47. /// @}
  48. } // namespace ranges
  49. #endif