VCCC  2024.05
VisualCamp Common C++ library
find_if_not.hpp
Go to the documentation of this file.
1 //
2 // Created by yonggyulee on 1/18/24.
3 //
4 
5 #ifndef VCCC_ALGORITHM_RANGES_FIND_IF_NOT_HPP
6 #define VCCC_ALGORITHM_RANGES_FIND_IF_NOT_HPP
7 
8 #include <functional>
9 #include <type_traits>
10 
16 #include "vccc/__ranges/begin.hpp"
18 #include "vccc/__ranges/end.hpp"
20 
21 namespace vccc {
22 namespace ranges {
23 namespace detail {
24 
25 struct find_if_not_niebloid {
26  template<typename I, typename S, typename Proj = identity, typename Pred, std::enable_if_t<
28  constexpr I operator()(I first, S last, Pred pred, Proj proj = {}) const {
29  using namespace vccc::rel_ops;
30  for (; first != last; ++first) {
31  if (!vccc::invoke(pred, vccc::invoke(proj, *first))) {
32  return first;
33  }
34  }
35  return first;
36  }
37 
38  template<typename R, typename Proj = identity, typename Pred, std::enable_if_t<
40  constexpr borrowed_iterator_t<R>
41  operator()(R&& r, Pred pred, Proj proj = {}) const {
42  return (*this)(ranges::begin(r), ranges::end(r), std::ref(pred), std::ref(proj));
43  }
44 };
45 
46 } // namespace detail
47 
50 
51 VCCC_INLINE_OR_STATIC constexpr detail::find_if_not_niebloid find_if_not{};
52 
54 
55 } // namespace ranges
56 } // namespace vccc
57 
58 #endif // VCCC_ALGORITHM_RANGES_FIND_IF_NOT_HPP
constexpr VCCC_INLINE_OR_STATIC detail::find_if_not_niebloid find_if_not
Definition: find_if_not.hpp:51
constexpr invoke_result_t< F, Args... > invoke(F &&f, Args &&... args) noexcept(is_nothrow_invocable< F, Args... >::value)
Definition: invoke.hpp:38
constexpr VCCC_INLINE_OR_STATIC detail::begin_niebloid begin
returns an iterator to the beginning of a range
Definition: begin.hpp:116
constexpr VCCC_INLINE_OR_STATIC detail::end_niebloid end
returns a sentinel indicating the end of a range
Definition: end.hpp:120
#define VCCC_INLINE_OR_STATIC
Definition: inline_or_static.hpp:9
Definition: cxx20_rel_ops.hpp:17
Definition: directory.h:12
constexpr VCCC_INLINE_OR_STATIC detail::element_niebloid< 0 > first
Definition: key_value.hpp:34
constexpr VCCC_INLINE_OR_STATIC detail::element_niebloid< 1 > value
Definition: key_value.hpp:35