您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

73 行
2.3KB

  1. /// \file
  2. // Range v3 library
  3. //
  4. // Copyright Eric Niebler 2014-present
  5. //
  6. // Use, modification and distribution is subject to the
  7. // Boost Software License, Version 1.0. (See accompanying
  8. // file LICENSE_1_0.txt or copy at
  9. // http://www.boost.org/LICENSE_1_0.txt)
  10. //
  11. // Project home: https://github.com/ericniebler/range-v3
  12. //
  13. #ifndef RANGES_V3_ALGORITHM_REVERSE_COPY_HPP
  14. #define RANGES_V3_ALGORITHM_REVERSE_COPY_HPP
  15. #include <meta/meta.hpp>
  16. #include <range/v3/range_fwd.hpp>
  17. #include <range/v3/algorithm/result_types.hpp>
  18. #include <range/v3/iterator/concepts.hpp>
  19. #include <range/v3/iterator/operations.hpp>
  20. #include <range/v3/iterator/traits.hpp>
  21. #include <range/v3/range/access.hpp>
  22. #include <range/v3/range/concepts.hpp>
  23. #include <range/v3/range/dangling.hpp>
  24. #include <range/v3/range/traits.hpp>
  25. #include <range/v3/utility/static_const.hpp>
  26. namespace ranges
  27. {
  28. /// \addtogroup group-algorithms
  29. /// @{
  30. template<typename I, typename O>
  31. using reverse_copy_result = detail::in_out_result<I, O>;
  32. RANGES_BEGIN_NIEBLOID(reverse_copy)
  33. /// \brief function template \c reverse_copy
  34. template<typename I, typename S, typename O>
  35. auto RANGES_FUN_NIEBLOID(reverse_copy)(I first, S end_, O out) //
  36. ->CPP_ret(reverse_copy_result<I, O>)( //
  37. requires bidirectional_iterator<I> && sentinel_for<S, I> &&
  38. weakly_incrementable<O> && indirectly_copyable<I, O>)
  39. {
  40. I last = ranges::next(first, end_), res = last;
  41. for(; first != last; ++out)
  42. *out = *--last;
  43. return {res, out};
  44. }
  45. /// \overload
  46. template<typename Rng, typename O>
  47. auto RANGES_FUN_NIEBLOID(reverse_copy)(Rng && rng, O out) //
  48. ->CPP_ret(reverse_copy_result<safe_iterator_t<Rng>, O>)( //
  49. requires bidirectional_range<Rng> && weakly_incrementable<O> &&
  50. indirectly_copyable<iterator_t<Rng>, O>)
  51. {
  52. return (*this)(begin(rng), end(rng), std::move(out));
  53. }
  54. RANGES_END_NIEBLOID(reverse_copy)
  55. namespace cpp20
  56. {
  57. using ranges::reverse_copy;
  58. using ranges::reverse_copy_result;
  59. } // namespace cpp20
  60. /// @}
  61. } // namespace ranges
  62. #endif // include guard