Path: blob/main/contrib/llvm-project/libcxx/include/__algorithm/copy_if.h
35233 views
//===----------------------------------------------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#ifndef _LIBCPP___ALGORITHM_COPY_IF_H9#define _LIBCPP___ALGORITHM_COPY_IF_H1011#include <__config>1213#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)14# pragma GCC system_header15#endif1617_LIBCPP_BEGIN_NAMESPACE_STD1819template <class _InputIterator, class _OutputIterator, class _Predicate>20inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator21copy_if(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _Predicate __pred) {22for (; __first != __last; ++__first) {23if (__pred(*__first)) {24*__result = *__first;25++__result;26}27}28return __result;29}3031_LIBCPP_END_NAMESPACE_STD3233#endif // _LIBCPP___ALGORITHM_COPY_IF_H343536