1290494Sbapt//===----------------------------------------------------------------------===// 2290494Sbapt// 3290494Sbapt// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4290494Sbapt// See https://llvm.org/LICENSE.txt for license information. 5127474Stjr// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6174990Sache// 7290494Sbapt//===----------------------------------------------------------------------===// 8290494Sbapt 9290494Sbapt#ifndef _LIBCPP___ALGORITHM_REPLACE_COPY_IF_H 10290494Sbapt#define _LIBCPP___ALGORITHM_REPLACE_COPY_IF_H 11290494Sbapt 12290494Sbapt#include <__config> 13290494Sbapt 14290494Sbapt#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 15290494Sbapt# pragma GCC system_header 16290494Sbapt#endif 17290494Sbapt 18290494Sbapt_LIBCPP_BEGIN_NAMESPACE_STD 19127474Stjr 20174990Sachetemplate <class _InputIterator, class _OutputIterator, class _Predicate, class _Tp> 21290494Sbaptinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 22290494Sbapt_OutputIterator 23290494Sbaptreplace_copy_if(_InputIterator __first, _InputIterator __last, _OutputIterator __result, 24290494Sbapt _Predicate __pred, const _Tp& __new_value) 25290494Sbapt{ 26290494Sbapt for (; __first != __last; ++__first, (void) ++__result) 27290494Sbapt if (__pred(*__first)) 28290494Sbapt *__result = __new_value; 29290494Sbapt else 30290494Sbapt *__result = *__first; 31290494Sbapt return __result; 32290494Sbapt} 33127474Stjr 34127474Stjr_LIBCPP_END_NAMESPACE_STD 35290494Sbapt 36290494Sbapt#endif // _LIBCPP___ALGORITHM_REPLACE_COPY_IF_H 37290494Sbapt