VCCC  2024.05
VisualCamp Common C++ library
any_of.hpp
Go to the documentation of this file.
1 //
2 // Created by yonggyulee on 1/26/24.
3 //
4 
5 #ifndef VCCC_ALGORITHM_RANGES_ANY_OF_HPP
6 #define VCCC_ALGORITHM_RANGES_ANY_OF_HPP
7 
8 #include <functional>
9 #include <type_traits>
10 
16 #include "vccc/__ranges/begin.hpp"
17 #include "vccc/__ranges/end.hpp"
18 
19 namespace vccc {
20 namespace ranges {
21 namespace detail {
22 
23 struct any_of_niebloid {
24  template<typename I, typename S, typename Proj = identity, typename Pred, std::enable_if_t<
25  algo_check_unary_input_iterator<indirect_unary_predicate, I, S, Proj, Pred>
26  ::value, int> = 0>
27  constexpr bool operator()(I first, S last, Pred pred, Proj proj = {}) const {
28  return ranges::find_if(first, last, std::ref(pred), std::ref(proj)) != last;
29  }
30 
31  template<typename R, typename Proj = identity, typename Pred, std::enable_if_t<
32  algo_check_unary_input_range<indirect_unary_predicate, R, Proj, Pred>
33  ::value, int> = 0>
34  constexpr bool operator()(R&& r, Pred pred, Proj proj = {}) const {
35  return (*this)(ranges::begin(r), ranges::end(r), std::ref(pred), std::ref(proj));
36  }
37 };
38 
39 } // namespace detail
40 
43 
44 VCCC_INLINE_OR_STATIC constexpr detail::any_of_niebloid any_of{};
45 
47 
48 } // namespace ranges
49 } // namespace vccc
50 
51 #endif // VCCC_ALGORITHM_RANGES_ANY_OF_HPP
constexpr VCCC_INLINE_OR_STATIC detail::any_of_niebloid any_of
Definition: any_of.hpp:44
constexpr VCCC_INLINE_OR_STATIC detail::find_if_niebloid find_if
Definition: find_if.hpp:53
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: 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