Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-03 08:13:36

0001 // -*- C++ -*-
0002 //===----------------------------------------------------------------------===//
0003 //
0004 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0005 // See https://llvm.org/LICENSE.txt for license information.
0006 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0007 //
0008 //===----------------------------------------------------------------------===//
0009 
0010 #ifndef _LIBCPP___CXX03___NUMERIC_INCLUSIVE_SCAN_H
0011 #define _LIBCPP___CXX03___NUMERIC_INCLUSIVE_SCAN_H
0012 
0013 #include <__cxx03/__config>
0014 #include <__cxx03/__functional/operations.h>
0015 #include <__cxx03/__iterator/iterator_traits.h>
0016 #include <__cxx03/__utility/move.h>
0017 
0018 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0019 #  pragma GCC system_header
0020 #endif
0021 
0022 _LIBCPP_BEGIN_NAMESPACE_STD
0023 
0024 #if _LIBCPP_STD_VER >= 17
0025 
0026 template <class _InputIterator, class _OutputIterator, class _Tp, class _BinaryOp>
0027 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator
0028 inclusive_scan(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryOp __b, _Tp __init) {
0029   for (; __first != __last; ++__first, (void)++__result) {
0030     __init    = __b(__init, *__first);
0031     *__result = __init;
0032   }
0033   return __result;
0034 }
0035 
0036 template <class _InputIterator, class _OutputIterator, class _BinaryOp>
0037 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator
0038 inclusive_scan(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryOp __b) {
0039   if (__first != __last) {
0040     typename iterator_traits<_InputIterator>::value_type __init = *__first;
0041     *__result++                                                 = __init;
0042     if (++__first != __last)
0043       return std::inclusive_scan(__first, __last, __result, __b, __init);
0044   }
0045 
0046   return __result;
0047 }
0048 
0049 template <class _InputIterator, class _OutputIterator>
0050 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator
0051 inclusive_scan(_InputIterator __first, _InputIterator __last, _OutputIterator __result) {
0052   return std::inclusive_scan(__first, __last, __result, std::plus<>());
0053 }
0054 
0055 #endif // _LIBCPP_STD_VER >= 17
0056 
0057 _LIBCPP_END_NAMESPACE_STD
0058 
0059 #endif // _LIBCPP___CXX03___NUMERIC_INCLUSIVE_SCAN_H