You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

erase.hpp 2.0KB

5 jaren geleden
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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_ACTION_ERASE_HPP
  14. #define RANGES_V3_ACTION_ERASE_HPP
  15. #include <utility>
  16. #include <range/v3/range_fwd.hpp>
  17. #include <range/v3/action/insert.hpp>
  18. #include <range/v3/utility/static_const.hpp>
  19. namespace ranges
  20. {
  21. /// \cond
  22. namespace adl_erase_detail
  23. {
  24. template<typename Cont, typename I, typename S>
  25. auto erase(Cont && cont, I first, S last) //
  26. -> CPP_ret(decltype(unwrap_reference(cont).erase(first, last)))( //
  27. requires lvalue_container_like<Cont> && forward_iterator<I> &&
  28. sentinel_for<S, I>)
  29. {
  30. return unwrap_reference(cont).erase(first, last);
  31. }
  32. struct erase_fn
  33. {
  34. template<typename Rng, typename I, typename S>
  35. auto operator()(Rng && rng, I first, S last) const
  36. -> CPP_ret(decltype(erase((Rng &&) rng, first, last)))( //
  37. requires range<Rng> && forward_iterator<I> && sentinel_for<S, I>)
  38. {
  39. return erase(static_cast<Rng &&>(rng), first, last);
  40. }
  41. };
  42. } // namespace adl_erase_detail
  43. /// \endcond
  44. /// \ingroup group-actions
  45. RANGES_INLINE_VARIABLE(adl_erase_detail::erase_fn, erase)
  46. namespace actions
  47. {
  48. using ranges::erase;
  49. }
  50. /// \addtogroup group-range
  51. /// @{
  52. // clang-format off
  53. CPP_def
  54. (
  55. template(typename Rng, typename I, typename S)
  56. concept erasable_range,
  57. requires (Rng &&rng, I first, S last)
  58. (
  59. ranges::erase(static_cast<Rng &&>(rng), first, last)
  60. ) &&
  61. range<Rng>
  62. );
  63. // clang-format on
  64. /// @}
  65. } // namespace ranges
  66. #endif