Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

rotate_copy.hpp 2.4KB

il y a 5 ans
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /// \file
  2. // Range v3 library
  3. //
  4. // Copyright Eric Niebler 2013-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_ROTATE_COPY_HPP
  14. #define RANGES_V3_ALGORITHM_ROTATE_COPY_HPP
  15. #include <functional>
  16. #include <range/v3/range_fwd.hpp>
  17. #include <range/v3/algorithm/copy.hpp>
  18. #include <range/v3/algorithm/result_types.hpp>
  19. #include <range/v3/functional/identity.hpp>
  20. #include <range/v3/iterator/concepts.hpp>
  21. #include <range/v3/iterator/traits.hpp>
  22. #include <range/v3/range/access.hpp>
  23. #include <range/v3/range/concepts.hpp>
  24. #include <range/v3/range/dangling.hpp>
  25. #include <range/v3/range/traits.hpp>
  26. #include <range/v3/utility/static_const.hpp>
  27. namespace ranges
  28. {
  29. /// \addtogroup group-algorithms
  30. /// @{
  31. template<typename I, typename O>
  32. using rotate_copy_result = detail::in_out_result<I, O>;
  33. RANGES_BEGIN_NIEBLOID(rotate_copy)
  34. /// \brief function template \c rotate_copy
  35. template<typename I, typename S, typename O, typename P = identity>
  36. auto RANGES_FUN_NIEBLOID(rotate_copy)(I first, I middle, S last, O out) //
  37. ->CPP_ret(rotate_copy_result<I, O>)( //
  38. requires forward_iterator<I> && sentinel_for<S, I> &&
  39. weakly_incrementable<O> && indirectly_copyable<I, O>)
  40. {
  41. auto res = ranges::copy(middle, std::move(last), std::move(out));
  42. return {std::move(res.in),
  43. ranges::copy(std::move(first), middle, std::move(res.out)).out};
  44. }
  45. /// \overload
  46. template<typename Rng, typename O, typename P = identity>
  47. auto RANGES_FUN_NIEBLOID(rotate_copy)(
  48. Rng && rng, iterator_t<Rng> middle, O out) //
  49. ->CPP_ret(rotate_copy_result<safe_iterator_t<Rng>, O>)( //
  50. requires range<Rng> && weakly_incrementable<O> &&
  51. indirectly_copyable<iterator_t<Rng>, O>)
  52. {
  53. return (*this)(begin(rng), std::move(middle), end(rng), std::move(out));
  54. }
  55. RANGES_END_NIEBLOID(rotate_copy)
  56. namespace cpp20
  57. {
  58. using ranges::rotate_copy;
  59. using ranges::rotate_copy_result;
  60. } // namespace cpp20
  61. /// @}
  62. } // namespace ranges
  63. #endif // include guard