1*4bdff4beSrobert //===----------------------------------------------------------------------===// 2*4bdff4beSrobert // 3*4bdff4beSrobert // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*4bdff4beSrobert // See https://llvm.org/LICENSE.txt for license information. 5*4bdff4beSrobert // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*4bdff4beSrobert // 7*4bdff4beSrobert //===----------------------------------------------------------------------===// 8*4bdff4beSrobert 9*4bdff4beSrobert #ifndef _LIBCPP___ALGORITHM_RANGES_NONE_OF_H 10*4bdff4beSrobert #define _LIBCPP___ALGORITHM_RANGES_NONE_OF_H 11*4bdff4beSrobert 12*4bdff4beSrobert #include <__config> 13*4bdff4beSrobert #include <__functional/identity.h> 14*4bdff4beSrobert #include <__functional/invoke.h> 15*4bdff4beSrobert #include <__iterator/concepts.h> 16*4bdff4beSrobert #include <__iterator/projected.h> 17*4bdff4beSrobert #include <__ranges/access.h> 18*4bdff4beSrobert #include <__ranges/concepts.h> 19*4bdff4beSrobert #include <__utility/move.h> 20*4bdff4beSrobert 21*4bdff4beSrobert #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 22*4bdff4beSrobert # pragma GCC system_header 23*4bdff4beSrobert #endif 24*4bdff4beSrobert 25*4bdff4beSrobert #if _LIBCPP_STD_VER > 17 26*4bdff4beSrobert 27*4bdff4beSrobert _LIBCPP_BEGIN_NAMESPACE_STD 28*4bdff4beSrobert 29*4bdff4beSrobert namespace ranges { 30*4bdff4beSrobert namespace __none_of { 31*4bdff4beSrobert struct __fn { 32*4bdff4beSrobert 33*4bdff4beSrobert template <class _Iter, class _Sent, class _Proj, class _Pred> 34*4bdff4beSrobert _LIBCPP_HIDE_FROM_ABI constexpr static __none_of_impl__fn35*4bdff4beSrobert bool __none_of_impl(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) { 36*4bdff4beSrobert for (; __first != __last; ++__first) { 37*4bdff4beSrobert if (std::invoke(__pred, std::invoke(__proj, *__first))) 38*4bdff4beSrobert return false; 39*4bdff4beSrobert } 40*4bdff4beSrobert return true; 41*4bdff4beSrobert } 42*4bdff4beSrobert 43*4bdff4beSrobert template <input_iterator _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity, 44*4bdff4beSrobert indirect_unary_predicate<projected<_Iter, _Proj>> _Pred> 45*4bdff4beSrobert _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr operator__fn46*4bdff4beSrobert bool operator()(_Iter __first, _Sent __last, _Pred __pred = {}, _Proj __proj = {}) const { 47*4bdff4beSrobert return __none_of_impl(std::move(__first), std::move(__last), __pred, __proj); 48*4bdff4beSrobert } 49*4bdff4beSrobert 50*4bdff4beSrobert template <input_range _Range, class _Proj = identity, 51*4bdff4beSrobert indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred> 52*4bdff4beSrobert _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr operator__fn53*4bdff4beSrobert bool operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const { 54*4bdff4beSrobert return __none_of_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj); 55*4bdff4beSrobert } 56*4bdff4beSrobert }; 57*4bdff4beSrobert } // namespace __none_of 58*4bdff4beSrobert 59*4bdff4beSrobert inline namespace __cpo { 60*4bdff4beSrobert inline constexpr auto none_of = __none_of::__fn{}; 61*4bdff4beSrobert } // namespace __cpo 62*4bdff4beSrobert } // namespace ranges 63*4bdff4beSrobert 64*4bdff4beSrobert _LIBCPP_END_NAMESPACE_STD 65*4bdff4beSrobert 66*4bdff4beSrobert #endif // _LIBCPP_STD_VER > 17 67*4bdff4beSrobert 68*4bdff4beSrobert #endif // _LIBCPP___ALGORITHM_RANGES_NONE_OF_H 69