Warning: This file is not a C or C++ file. It does not have highlighting.
1 | // -*- C++ -*- |
---|---|
2 | //===----------------------------------------------------------------------===// |
3 | // |
4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
5 | // See https://llvm.org/LICENSE.txt for license information. |
6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
7 | // |
8 | //===----------------------------------------------------------------------===// |
9 | |
10 | #ifndef _LIBCPP___NUMERIC_TRANSFORM_INCLUSIVE_SCAN_H |
11 | #define _LIBCPP___NUMERIC_TRANSFORM_INCLUSIVE_SCAN_H |
12 | |
13 | #include <__config> |
14 | #include <__iterator/iterator_traits.h> |
15 | |
16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
17 | # pragma GCC system_header |
18 | #endif |
19 | |
20 | _LIBCPP_BEGIN_NAMESPACE_STD |
21 | |
22 | #if _LIBCPP_STD_VER >= 17 |
23 | |
24 | template <class _InputIterator, class _OutputIterator, class _Tp, class _BinaryOp, class _UnaryOp> |
25 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator transform_inclusive_scan( |
26 | _InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryOp __b, _UnaryOp __u, _Tp __init) { |
27 | for (; __first != __last; ++__first, (void)++__result) { |
28 | __init = __b(__init, __u(*__first)); |
29 | *__result = __init; |
30 | } |
31 | |
32 | return __result; |
33 | } |
34 | |
35 | template <class _InputIterator, class _OutputIterator, class _BinaryOp, class _UnaryOp> |
36 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator transform_inclusive_scan( |
37 | _InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryOp __b, _UnaryOp __u) { |
38 | if (__first != __last) { |
39 | typename iterator_traits<_InputIterator>::value_type __init = __u(*__first); |
40 | *__result++ = __init; |
41 | if (++__first != __last) |
42 | return std::transform_inclusive_scan(__first, __last, __result, __b, __u, __init); |
43 | } |
44 | |
45 | return __result; |
46 | } |
47 | |
48 | #endif // _LIBCPP_STD_VER >= 17 |
49 | |
50 | _LIBCPP_END_NAMESPACE_STD |
51 | |
52 | #endif // _LIBCPP___NUMERIC_TRANSFORM_INCLUSIVE_SCAN_H |
53 |
Warning: This file is not a C or C++ file. It does not have highlighting.