xref: /freebsd-src/contrib/llvm-project/libcxx/include/__numeric/transform_exclusive_scan.h (revision cb14a3fe5122c879eae1fb480ed7ce82a699ddb6)
14824e7fdSDimitry Andric // -*- C++ -*-
24824e7fdSDimitry Andric //===----------------------------------------------------------------------===//
34824e7fdSDimitry Andric //
44824e7fdSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
54824e7fdSDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
64824e7fdSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
74824e7fdSDimitry Andric //
84824e7fdSDimitry Andric //===----------------------------------------------------------------------===//
94824e7fdSDimitry Andric 
104824e7fdSDimitry Andric #ifndef _LIBCPP___NUMERIC_TRANSFORM_EXCLUSIVE_SCAN_H
114824e7fdSDimitry Andric #define _LIBCPP___NUMERIC_TRANSFORM_EXCLUSIVE_SCAN_H
124824e7fdSDimitry Andric 
134824e7fdSDimitry Andric #include <__config>
144824e7fdSDimitry Andric 
154824e7fdSDimitry Andric #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
164824e7fdSDimitry Andric #  pragma GCC system_header
174824e7fdSDimitry Andric #endif
184824e7fdSDimitry Andric 
194824e7fdSDimitry Andric _LIBCPP_BEGIN_NAMESPACE_STD
204824e7fdSDimitry Andric 
2106c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 17
224824e7fdSDimitry Andric 
23*cb14a3feSDimitry Andric template <class _InputIterator, class _OutputIterator, class _Tp, class _BinaryOp, class _UnaryOp>
transform_exclusive_scan(_InputIterator __first,_InputIterator __last,_OutputIterator __result,_Tp __init,_BinaryOp __b,_UnaryOp __u)24*cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator transform_exclusive_scan(
25*cb14a3feSDimitry Andric     _InputIterator __first, _InputIterator __last, _OutputIterator __result, _Tp __init, _BinaryOp __b, _UnaryOp __u) {
26*cb14a3feSDimitry Andric   if (__first != __last) {
274824e7fdSDimitry Andric     _Tp __saved = __init;
28*cb14a3feSDimitry Andric     do {
294824e7fdSDimitry Andric       __init    = __b(__init, __u(*__first));
304824e7fdSDimitry Andric       *__result = __saved;
314824e7fdSDimitry Andric       __saved   = __init;
324824e7fdSDimitry Andric       ++__result;
334824e7fdSDimitry Andric     } while (++__first != __last);
344824e7fdSDimitry Andric   }
354824e7fdSDimitry Andric   return __result;
364824e7fdSDimitry Andric }
374824e7fdSDimitry Andric 
3806c3fb27SDimitry Andric #endif // _LIBCPP_STD_VER >= 17
394824e7fdSDimitry Andric 
404824e7fdSDimitry Andric _LIBCPP_END_NAMESPACE_STD
414824e7fdSDimitry Andric 
424824e7fdSDimitry Andric #endif // _LIBCPP___NUMERIC_TRANSFORM_EXCLUSIVE_SCAN_H
43