Please use GitHub pull requests for new patches. Avoid migrating existing patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
libcxx/include/__algorithm/none_of.h
// -*- C++ -*- | // -*- C++ -*- | ||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
// | // | ||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||||
// See https://llvm.org/LICENSE.txt for license information. | // See https://llvm.org/LICENSE.txt for license information. | ||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||||
// | // | ||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
#ifndef _LIBCPP___ALGORITHM_NONE_OF_H | #ifndef _LIBCPP___ALGORITHM_NONE_OF_H | ||||
#define _LIBCPP___ALGORITHM_NONE_OF_H | #define _LIBCPP___ALGORITHM_NONE_OF_H | ||||
#include <__algorithm/any_of.h> | |||||
#include <__config> | #include <__config> | ||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||||
# pragma GCC system_header | # pragma GCC system_header | ||||
#endif | #endif | ||||
_LIBCPP_BEGIN_NAMESPACE_STD | _LIBCPP_BEGIN_NAMESPACE_STD | ||||
template <class _InputIterator, class _Predicate> | template <class _InputIterator, class _Predicate> | ||||
_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | ||||
none_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) { | none_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) { | ||||
for (; __first != __last; ++__first) | for (; __first != __last; ++__first) | ||||
if (__pred(*__first)) | if (__pred(*__first)) | ||||
return false; | return false; | ||||
return true; | return true; | ||||
} | } | ||||
#if defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 17 | |||||
template <class _ExecutionPolicy, | |||||
class _ForwardIterator, | |||||
class _Pred, | |||||
enable_if_t<is_execution_policy_v<remove_cvref_t<_ExecutionPolicy>>, int> = 0> | |||||
_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI bool | |||||
none_of(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Pred __pred) { | |||||
return !std::any_of(__policy, __first, __last, __pred); | |||||
} | |||||
#endif // defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 17 | |||||
_LIBCPP_END_NAMESPACE_STD | _LIBCPP_END_NAMESPACE_STD | ||||
#endif // _LIBCPP___ALGORITHM_NONE_OF_H | #endif // _LIBCPP___ALGORITHM_NONE_OF_H |