brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.2 KiB · a161282 Raw
74 lines · c
1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef _LIBCPP___ALGORITHM_RANGES_NONE_OF_H10#define _LIBCPP___ALGORITHM_RANGES_NONE_OF_H11 12#include <__config>13#include <__functional/identity.h>14#include <__functional/invoke.h>15#include <__iterator/concepts.h>16#include <__iterator/projected.h>17#include <__ranges/access.h>18#include <__ranges/concepts.h>19#include <__utility/move.h>20 21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)22#  pragma GCC system_header23#endif24 25_LIBCPP_PUSH_MACROS26#include <__undef_macros>27 28#if _LIBCPP_STD_VER >= 2029 30_LIBCPP_BEGIN_NAMESPACE_STD31 32namespace ranges {33struct __none_of {34  template <class _Iter, class _Sent, class _Proj, class _Pred>35  _LIBCPP_HIDE_FROM_ABI constexpr static bool36  __none_of_impl(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) {37    for (; __first != __last; ++__first) {38      if (std::invoke(__pred, std::invoke(__proj, *__first)))39        return false;40    }41    return true;42  }43 44  template <input_iterator _Iter,45            sentinel_for<_Iter> _Sent,46            class _Proj = identity,47            indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>48  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool49  operator()(_Iter __first, _Sent __last, _Pred __pred = {}, _Proj __proj = {}) const {50    return __none_of_impl(std::move(__first), std::move(__last), __pred, __proj);51  }52 53  template <input_range _Range,54            class _Proj = identity,55            indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>56  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool57  operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const {58    return __none_of_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);59  }60};61 62inline namespace __cpo {63inline constexpr auto none_of = __none_of{};64} // namespace __cpo65} // namespace ranges66 67_LIBCPP_END_NAMESPACE_STD68 69#endif // _LIBCPP_STD_VER >= 2070 71_LIBCPP_POP_MACROS72 73#endif // _LIBCPP___ALGORITHM_RANGES_NONE_OF_H74