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.

69 lines
2.1KB

  1. /// \file
  2. // Range v3 library
  3. //
  4. // Copyright Andrew Sutton 2014
  5. // Copyright Gonzalo Brito Gadeschi 2014
  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_ALGORITHM_NONE_OF_HPP
  15. #define RANGES_V3_ALGORITHM_NONE_OF_HPP
  16. #include <utility>
  17. #include <range/v3/range_fwd.hpp>
  18. #include <range/v3/functional/identity.hpp>
  19. #include <range/v3/functional/invoke.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/traits.hpp>
  25. #include <range/v3/utility/static_const.hpp>
  26. namespace ranges
  27. {
  28. /// \addtogroup group-algorithms
  29. /// @{
  30. RANGES_BEGIN_NIEBLOID(none_of)
  31. /// \brief function template \c none_of
  32. template<typename I, typename S, typename F, typename P = identity>
  33. auto RANGES_FUN_NIEBLOID(none_of)(I first, S last, F pred, P proj = P{}) //
  34. ->CPP_ret(bool)( //
  35. requires input_iterator<I> && sentinel_for<S, I> &&
  36. indirect_unary_predicate<F, projected<I, P>>)
  37. {
  38. for(; first != last; ++first)
  39. if(invoke(pred, invoke(proj, *first)))
  40. return false;
  41. return true;
  42. }
  43. /// \overload
  44. template<typename Rng, typename F, typename P = identity>
  45. auto RANGES_FUN_NIEBLOID(none_of)(Rng && rng, F pred, P proj = P{}) //
  46. ->CPP_ret(bool)( //
  47. requires input_range<Rng> &&
  48. indirect_unary_predicate<F, projected<iterator_t<Rng>, P>>)
  49. {
  50. return (*this)(begin(rng), end(rng), std::move(pred), std::move(proj));
  51. }
  52. RANGES_END_NIEBLOID(none_of)
  53. namespace cpp20
  54. {
  55. using ranges::none_of;
  56. }
  57. /// @}
  58. } // namespace ranges
  59. #endif // include guard