File indexing completed on 2026-05-03 08:13:58
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef _LIBCPP___NUMERIC_INNER_PRODUCT_H
0011 #define _LIBCPP___NUMERIC_INNER_PRODUCT_H
0012
0013 #include <__config>
0014 #include <__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 <__undef_macros>
0022
0023 _LIBCPP_BEGIN_NAMESPACE_STD
0024
0025 template <class _InputIterator1, class _InputIterator2, class _Tp>
0026 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp
0027 inner_product(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _Tp __init) {
0028 for (; __first1 != __last1; ++__first1, (void)++__first2)
0029 #if _LIBCPP_STD_VER >= 20
0030 __init = std::move(__init) + *__first1 * *__first2;
0031 #else
0032 __init = __init + *__first1 * *__first2;
0033 #endif
0034 return __init;
0035 }
0036
0037 template <class _InputIterator1, class _InputIterator2, class _Tp, class _BinaryOperation1, class _BinaryOperation2>
0038 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp inner_product(
0039 _InputIterator1 __first1,
0040 _InputIterator1 __last1,
0041 _InputIterator2 __first2,
0042 _Tp __init,
0043 _BinaryOperation1 __binary_op1,
0044 _BinaryOperation2 __binary_op2) {
0045 for (; __first1 != __last1; ++__first1, (void)++__first2)
0046 #if _LIBCPP_STD_VER >= 20
0047 __init = __binary_op1(std::move(__init), __binary_op2(*__first1, *__first2));
0048 #else
0049 __init = __binary_op1(__init, __binary_op2(*__first1, *__first2));
0050 #endif
0051 return __init;
0052 }
0053
0054 _LIBCPP_END_NAMESPACE_STD
0055
0056 _LIBCPP_POP_MACROS
0057
0058 #endif