xref: /llvm-project/libcxx/include/__numeric/transform_exclusive_scan.h (revision 9783f28cbb155e4a8d49c12e1c60ce14dcfaf0c7)
1a0efb175SChristopher Di Bella // -*- C++ -*-
2a0efb175SChristopher Di Bella //===----------------------------------------------------------------------===//
3a0efb175SChristopher Di Bella //
4a0efb175SChristopher Di Bella // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5a0efb175SChristopher Di Bella // See https://llvm.org/LICENSE.txt for license information.
6a0efb175SChristopher Di Bella // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7a0efb175SChristopher Di Bella //
8a0efb175SChristopher Di Bella //===----------------------------------------------------------------------===//
9a0efb175SChristopher Di Bella 
10a0efb175SChristopher Di Bella #ifndef _LIBCPP___NUMERIC_TRANSFORM_EXCLUSIVE_SCAN_H
11a0efb175SChristopher Di Bella #define _LIBCPP___NUMERIC_TRANSFORM_EXCLUSIVE_SCAN_H
12a0efb175SChristopher Di Bella 
13a0efb175SChristopher Di Bella #include <__config>
14a0efb175SChristopher Di Bella 
15a0efb175SChristopher Di Bella #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16a0efb175SChristopher Di Bella #  pragma GCC system_header
17a0efb175SChristopher Di Bella #endif
18a0efb175SChristopher Di Bella 
19a0efb175SChristopher Di Bella _LIBCPP_BEGIN_NAMESPACE_STD
20a0efb175SChristopher Di Bella 
214f15267dSNikolas Klauser #if _LIBCPP_STD_VER >= 17
22a0efb175SChristopher Di Bella 
23*9783f28cSLouis Dionne 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*9783f28cSLouis Dionne _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator transform_exclusive_scan(
25*9783f28cSLouis Dionne     _InputIterator __first, _InputIterator __last, _OutputIterator __result, _Tp __init, _BinaryOp __b, _UnaryOp __u) {
26*9783f28cSLouis Dionne   if (__first != __last) {
27a0efb175SChristopher Di Bella     _Tp __saved = __init;
28*9783f28cSLouis Dionne     do {
29a0efb175SChristopher Di Bella       __init    = __b(__init, __u(*__first));
30a0efb175SChristopher Di Bella       *__result = __saved;
31a0efb175SChristopher Di Bella       __saved   = __init;
32a0efb175SChristopher Di Bella       ++__result;
33a0efb175SChristopher Di Bella     } while (++__first != __last);
34a0efb175SChristopher Di Bella   }
35a0efb175SChristopher Di Bella   return __result;
36a0efb175SChristopher Di Bella }
37a0efb175SChristopher Di Bella 
384f15267dSNikolas Klauser #endif // _LIBCPP_STD_VER >= 17
39a0efb175SChristopher Di Bella 
40a0efb175SChristopher Di Bella _LIBCPP_END_NAMESPACE_STD
41a0efb175SChristopher Di Bella 
42a0efb175SChristopher Di Bella #endif // _LIBCPP___NUMERIC_TRANSFORM_EXCLUSIVE_SCAN_H
43