Path: blob/main/contrib/llvm-project/libcxx/include/__numeric/exclusive_scan.h
35233 views
// -*- C++ -*-1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//89#ifndef _LIBCPP___NUMERIC_EXCLUSIVE_SCAN_H10#define _LIBCPP___NUMERIC_EXCLUSIVE_SCAN_H1112#include <__config>13#include <__functional/operations.h>14#include <__utility/move.h>1516#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17# pragma GCC system_header18#endif1920_LIBCPP_PUSH_MACROS21#include <__undef_macros>2223_LIBCPP_BEGIN_NAMESPACE_STD2425#if _LIBCPP_STD_VER >= 172627template <class _InputIterator, class _OutputIterator, class _Tp, class _BinaryOp>28_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator29exclusive_scan(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _Tp __init, _BinaryOp __b) {30if (__first != __last) {31_Tp __tmp(__b(__init, *__first));32while (true) {33*__result = std::move(__init);34++__result;35++__first;36if (__first == __last)37break;38__init = std::move(__tmp);39__tmp = __b(__init, *__first);40}41}42return __result;43}4445template <class _InputIterator, class _OutputIterator, class _Tp>46_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator47exclusive_scan(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _Tp __init) {48return std::exclusive_scan(__first, __last, __result, __init, std::plus<>());49}5051#endif // _LIBCPP_STD_VER >= 175253_LIBCPP_END_NAMESPACE_STD5455_LIBCPP_POP_MACROS5657#endif // _LIBCPP___NUMERIC_EXCLUSIVE_SCAN_H585960