From 3ad39e9878310e5317ee73c9b353c1e2c1c5c4ee Mon Sep 17 00:00:00 2001 From: Richard Qin Date: Sat, 11 Jul 2026 22:48:30 +0800 Subject: lib: establish Zircon libc++ and KTL foundation --- third_party/libcxx/include/c++/v1/numeric | 212 ++++++++++++++++++++++++++++++ 1 file changed, 212 insertions(+) create mode 100644 third_party/libcxx/include/c++/v1/numeric (limited to 'third_party/libcxx/include/c++/v1/numeric') diff --git a/third_party/libcxx/include/c++/v1/numeric b/third_party/libcxx/include/c++/v1/numeric new file mode 100644 index 0000000..64111b8 --- /dev/null +++ b/third_party/libcxx/include/c++/v1/numeric @@ -0,0 +1,212 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_NUMERIC +#define _LIBCPP_NUMERIC + +/* + numeric synopsis + +namespace std +{ + +template + constexpr T // constexpr since C++20 + accumulate(InputIterator first, InputIterator last, T init); + +template + constexpr T // constexpr since C++20 + accumulate(InputIterator first, InputIterator last, T init, BinaryOperation binary_op); + +template + constexpr typename iterator_traits::value_type // constexpr since C++20 + reduce(InputIterator first, InputIterator last); // C++17 + +template + constexpr T // constexpr since C++20 + reduce(InputIterator first, InputIterator last, T init); // C++17 + +template + constexpr T // constexpr since C++20 + reduce(InputIterator first, InputIterator last, T init, BinaryOperation binary_op); // C++17 + +template + constexpr T // constexpr since C++20 + inner_product(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, T init); + +template + constexpr T // constexpr since C++20 + inner_product(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, + T init, BinaryOperation1 binary_op1, BinaryOperation2 binary_op2); + + +template + constexpr T // constexpr since C++20 + transform_reduce(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, T init); // C++17 + +template + constexpr T // constexpr since C++20 + transform_reduce(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, T init, + BinaryOperation1 binary_op1, BinaryOperation2 binary_op2); // C++17 + +template + constexpr T // constexpr since C++20 + transform_reduce(InputIterator first, InputIterator last, T init, + BinaryOperation binary_op, UnaryOperation unary_op); // C++17 + +template + constexpr OutputIterator // constexpr since C++20 + partial_sum(InputIterator first, InputIterator last, OutputIterator result); + +template + constexpr OutputIterator // constexpr since C++20 + partial_sum(InputIterator first, InputIterator last, OutputIterator result, BinaryOperation binary_op); + +template + constexpr OutputIterator // constexpr since C++20 + exclusive_scan(InputIterator first, InputIterator last, + OutputIterator result, T init); // C++17 + +template + constexpr OutputIterator // constexpr since C++20 + exclusive_scan(InputIterator first, InputIterator last, + OutputIterator result, T init, BinaryOperation binary_op); // C++17 + +template + constexpr OutputIterator // constexpr since C++20 + inclusive_scan(InputIterator first, InputIterator last, OutputIterator result); // C++17 + +template + constexpr OutputIterator // constexpr since C++20 + inclusive_scan(InputIterator first, InputIterator last, + OutputIterator result, BinaryOperation binary_op); // C++17 + +template + constexpr OutputIterator // constexpr since C++20 + inclusive_scan(InputIterator first, InputIterator last, + OutputIterator result, BinaryOperation binary_op, T init); // C++17 + +template + constexpr OutputIterator // constexpr since C++20 + transform_exclusive_scan(InputIterator first, InputIterator last, + OutputIterator result, T init, + BinaryOperation binary_op, UnaryOperation unary_op); // C++17 + +template + constexpr OutputIterator // constexpr since C++20 + transform_inclusive_scan(InputIterator first, InputIterator last, + OutputIterator result, + BinaryOperation binary_op, UnaryOperation unary_op); // C++17 + +template + constexpr OutputIterator // constexpr since C++20 + transform_inclusive_scan(InputIterator first, InputIterator last, + OutputIterator result, + BinaryOperation binary_op, UnaryOperation unary_op, + T init); // C++17 + +template + constexpr OutputIterator // constexpr since C++20 + adjacent_difference(InputIterator first, InputIterator last, OutputIterator result); + +template + constexpr OutputIterator // constexpr since C++20 + adjacent_difference(InputIterator first, InputIterator last, OutputIterator result, BinaryOperation binary_op); + +template + constexpr void // constexpr since C++20 + iota(ForwardIterator first, ForwardIterator last, T value); + +template + constexpr common_type_t gcd(M m, N n); // C++17 + +template + constexpr common_type_t lcm(M m, N n); // C++17 + +template + constexpr T midpoint(T a, T b) noexcept; // C++20 + +template + constexpr T* midpoint(T* a, T* b); // C++20 + +// [numeric.sat], saturation arithmetic +template +constexpr T saturating_add(T x, T y) noexcept; // freestanding, Since C++26 +template +constexpr T saturating_sub(T x, T y) noexcept; // freestanding, Since C++26 +template +constexpr T saturating_mul(T x, T y) noexcept; // freestanding, Since C++26 +template +constexpr T saturating_div(T x, T y) noexcept; // freestanding, Since C++26 +template +constexpr T saturating_cast(U x) noexcept; // freestanding, Since C++26 + +} // std + +*/ + +#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) +# include <__cxx03/numeric> +#else +# include <__config> + +# include <__numeric/accumulate.h> +# include <__numeric/adjacent_difference.h> +# include <__numeric/inner_product.h> +# include <__numeric/iota.h> +# include <__numeric/partial_sum.h> + +# if _LIBCPP_STD_VER >= 17 +# include <__numeric/exclusive_scan.h> +# include <__numeric/gcd_lcm.h> +# include <__numeric/inclusive_scan.h> +# include <__numeric/pstl.h> +# include <__numeric/ranges_iota.h> +# include <__numeric/reduce.h> +# include <__numeric/transform_exclusive_scan.h> +# include <__numeric/transform_inclusive_scan.h> +# include <__numeric/transform_reduce.h> +# endif + +# if _LIBCPP_STD_VER >= 20 +# include <__numeric/midpoint.h> +# include <__numeric/saturation_arithmetic.h> +# endif + +# include + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif + +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 14 +# include +# include +# endif + +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# endif +#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) + +#endif // _LIBCPP_NUMERIC -- cgit v1.2.3