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_ACCUMULATE_H
0011 #define _LIBCPP___CXX03___NUMERIC_ACCUMULATE_H
0012 
0013 #include <__cxx03/__config>
0014 #include <__cxx03/__utility/move.h>
0015 
0016 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0017 #  pragma GCC system_header
0018 #endif
0019 
0020 _LIBCPP_PUSH_MACROS
0021 #include <__cxx03/__undef_macros>
0022 
0023 _LIBCPP_BEGIN_NAMESPACE_STD
0024 
0025 template <class _InputIterator, class _Tp>
0026 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp
0027 accumulate(_InputIterator __first, _InputIterator __last, _Tp __init) {
0028   for (; __first != __last; ++__first)
0029 #if _LIBCPP_STD_VER >= 20
0030     __init = std::move(__init) + *__first;
0031 #else
0032     __init = __init + *__first;
0033 #endif
0034   return __init;
0035 }
0036 
0037 template <class _InputIterator, class _Tp, class _BinaryOperation>
0038 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp
0039 accumulate(_InputIterator __first, _InputIterator __last, _Tp __init, _BinaryOperation __binary_op) {
0040   for (; __first != __last; ++__first)
0041 #if _LIBCPP_STD_VER >= 20
0042     __init = __binary_op(std::move(__init), *__first);
0043 #else
0044     __init = __binary_op(__init, *__first);
0045 #endif
0046   return __init;
0047 }
0048 
0049 _LIBCPP_END_NAMESPACE_STD
0050 
0051 _LIBCPP_POP_MACROS
0052 
0053 #endif // _LIBCPP___CXX03___NUMERIC_ACCUMULATE_H