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.

66 satır
1.9KB

  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_DROP_WHILE_HPP
  14. #define RANGES_V3_ACTION_DROP_WHILE_HPP
  15. #include <range/v3/range_fwd.hpp>
  16. #include <range/v3/action/action.hpp>
  17. #include <range/v3/action/erase.hpp>
  18. #include <range/v3/algorithm/find_if_not.hpp>
  19. #include <range/v3/functional/bind_back.hpp>
  20. #include <range/v3/iterator/concepts.hpp>
  21. #include <range/v3/iterator/traits.hpp>
  22. #include <range/v3/utility/static_const.hpp>
  23. namespace ranges
  24. {
  25. /// \addtogroup group-actions
  26. /// @{
  27. namespace actions
  28. {
  29. struct drop_while_fn
  30. {
  31. private:
  32. friend action_access;
  33. template<typename Fun>
  34. static auto CPP_fun(bind)(drop_while_fn drop_while, Fun fun)( //
  35. requires(!range<Fun>))
  36. {
  37. return bind_back(drop_while, std::move(fun));
  38. }
  39. public:
  40. template<typename Rng, typename Fun>
  41. auto operator()(Rng && rng, Fun fun) const -> CPP_ret(Rng)( //
  42. requires forward_range<Rng> &&
  43. indirect_unary_predicate<Fun, iterator_t<Rng>> &&
  44. erasable_range<Rng &, iterator_t<Rng>, iterator_t<Rng>>)
  45. {
  46. ranges::actions::erase(
  47. rng, begin(rng), find_if_not(begin(rng), end(rng), std::move(fun)));
  48. return static_cast<Rng &&>(rng);
  49. }
  50. };
  51. /// \ingroup group-actions
  52. /// \relates drop_while_fn
  53. /// \sa action
  54. RANGES_INLINE_VARIABLE(action<drop_while_fn>, drop_while)
  55. } // namespace actions
  56. /// @}
  57. } // namespace ranges
  58. #endif