Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libcxx/docs/FeatureTestMacroTable.rst
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ Status
---------------------------------------------------------- -----------------
``__cpp_lib_reference_wrapper`` ``202403L``
---------------------------------------------------------- -----------------
``__cpp_lib_saturation_arithmetic`` ``202311L``
``__cpp_lib_saturation_arithmetic`` ``202603L``
---------------------------------------------------------- -----------------
``__cpp_lib_senders`` *unimplemented*
---------------------------------------------------------- -----------------
Expand Down
1 change: 1 addition & 0 deletions libcxx/docs/ReleaseNotes/23.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Implemented Papers
- P2440R1: ``ranges::iota``, ``ranges::shift_left`` and ``ranges::shift_right`` (`Github <https://llvm.org/PR105184>`__)
- P3936R1: Safer ``atomic_ref::address`` (`Github <https://llvm.org/PR189594>`__)
- P3953R3: Rename ``std::runtime_format`` (`Github <https://llvm.org/PR189624>`__)
- P4052R0: Renaming saturation arithmetic functions (`Github <https://llvm.org/PR189589>`__)

Improvements and New Features
-----------------------------
Expand Down
2 changes: 1 addition & 1 deletion libcxx/docs/Status/Cxx2cPapers.csv
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@
"`P3980R1 <https://wg21.link/P3980R1>`__","Task's Allocator Use","2026-03 (Croydon)","","","`#189621 <https://github.com/llvm/llvm-project/issues/189621>`__",""
"`P4156R0 <https://wg21.link/P4156R0>`__","Rename meta::has_ellipsis_parameter to meta::is_vararg_function","2026-03 (Croydon)","","","`#189622 <https://github.com/llvm/llvm-project/issues/189622>`__",""
"`P3953R3 <https://wg21.link/P3953R3>`__","Rename ``std::runtime_format``","2026-03 (Croydon)","|Complete|","23","`#189624 <https://github.com/llvm/llvm-project/issues/189624>`__",""
"`P4052R0 <https://wg21.link/P4052R0>`__","Renaming saturation arithmetic functions","2026-03 (Croydon)","","","`#189589 <https://github.com/llvm/llvm-project/issues/189589>`__",""
"`P4052R0 <https://wg21.link/P4052R0>`__","Renaming saturation arithmetic functions","2026-03 (Croydon)","|Complete|","23","`#189589 <https://github.com/llvm/llvm-project/issues/189589>`__",""
"`P3941R4 <https://wg21.link/P3941R4>`__","Scheduler Affinity","2026-03 (Croydon)","","","`#189627 <https://github.com/llvm/llvm-project/issues/189627>`__",""
"`P3856R8 <https://wg21.link/P3856R8>`__","New reflection metafunction - is_structural_type (US NB comment 49)","2026-03 (Croydon)","","","`#189625 <https://github.com/llvm/llvm-project/issues/189625>`__",""
"`P3927R2 <https://wg21.link/P3927R2>`__","``task_scheduler`` support for parallel ``bulk`` execution","2026-03 (Croydon)","","","`#189629 <https://github.com/llvm/llvm-project/issues/189629>`__",""
Expand Down
30 changes: 15 additions & 15 deletions libcxx/include/__numeric/saturation_arithmetic.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER >= 20

template <__signed_or_unsigned_integer _Tp>
_LIBCPP_HIDE_FROM_ABI constexpr _Tp __add_sat(_Tp __x, _Tp __y) noexcept {
_LIBCPP_HIDE_FROM_ABI constexpr _Tp __saturating_add(_Tp __x, _Tp __y) noexcept {
# if defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER >= 2101
return __builtin_elementwise_add_sat(__x, __y);
# else
Expand All @@ -51,7 +51,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp __add_sat(_Tp __x, _Tp __y) noexcept {
}

template <__signed_or_unsigned_integer _Tp>
_LIBCPP_HIDE_FROM_ABI constexpr _Tp __sub_sat(_Tp __x, _Tp __y) noexcept {
_LIBCPP_HIDE_FROM_ABI constexpr _Tp __saturating_sub(_Tp __x, _Tp __y) noexcept {
# if defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER >= 2101
return __builtin_elementwise_sub_sat(__x, __y);
# else
Expand All @@ -74,7 +74,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp __sub_sat(_Tp __x, _Tp __y) noexcept {
}

template <__signed_or_unsigned_integer _Tp>
_LIBCPP_HIDE_FROM_ABI constexpr _Tp __mul_sat(_Tp __x, _Tp __y) noexcept {
_LIBCPP_HIDE_FROM_ABI constexpr _Tp __saturating_mul(_Tp __x, _Tp __y) noexcept {
if (_Tp __mul; !__builtin_mul_overflow(__x, __y, std::addressof(__mul)))
return __mul;
// Handle overflow
Expand All @@ -90,7 +90,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp __mul_sat(_Tp __x, _Tp __y) noexcept {
}

template <__signed_or_unsigned_integer _Tp>
_LIBCPP_HIDE_FROM_ABI constexpr _Tp __div_sat(_Tp __x, _Tp __y) noexcept {
_LIBCPP_HIDE_FROM_ABI constexpr _Tp __saturating_div(_Tp __x, _Tp __y) noexcept {
_LIBCPP_ASSERT_UNCATEGORIZED(__y != 0, "Division by 0 is undefined");
if constexpr (__unsigned_integer<_Tp>) {
return __x / __y;
Expand All @@ -103,7 +103,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp __div_sat(_Tp __x, _Tp __y) noexcept {
}

template <__signed_or_unsigned_integer _Rp, __signed_or_unsigned_integer _Tp>
_LIBCPP_HIDE_FROM_ABI constexpr _Rp __saturate_cast(_Tp __x) noexcept {
_LIBCPP_HIDE_FROM_ABI constexpr _Rp __saturating_cast(_Tp __x) noexcept {
// Saturation is impossible edge case when ((min _Rp) < (min _Tp) && (max _Rp) > (max _Tp)) and it is expected to be
// optimized out by the compiler.

Expand All @@ -121,28 +121,28 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Rp __saturate_cast(_Tp __x) noexcept {
#if _LIBCPP_STD_VER >= 26

template <__signed_or_unsigned_integer _Tp>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp add_sat(_Tp __x, _Tp __y) noexcept {
return std::__add_sat(__x, __y);
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp saturating_add(_Tp __x, _Tp __y) noexcept {
return std::__saturating_add(__x, __y);
}

template <__signed_or_unsigned_integer _Tp>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp sub_sat(_Tp __x, _Tp __y) noexcept {
return std::__sub_sat(__x, __y);
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp saturating_sub(_Tp __x, _Tp __y) noexcept {
return std::__saturating_sub(__x, __y);
}

template <__signed_or_unsigned_integer _Tp>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp mul_sat(_Tp __x, _Tp __y) noexcept {
return std::__mul_sat(__x, __y);
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp saturating_mul(_Tp __x, _Tp __y) noexcept {
return std::__saturating_mul(__x, __y);
}

template <__signed_or_unsigned_integer _Tp>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp div_sat(_Tp __x, _Tp __y) noexcept {
return std::__div_sat(__x, __y);
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp saturating_div(_Tp __x, _Tp __y) noexcept {
return std::__saturating_div(__x, __y);
}

template <__signed_or_unsigned_integer _Rp, __signed_or_unsigned_integer _Tp>
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Rp saturate_cast(_Tp __x) noexcept {
return std::__saturate_cast<_Rp>(__x);
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Rp saturating_cast(_Tp __x) noexcept {
return std::__saturating_cast<_Rp>(__x);
}

#endif // _LIBCPP_STD_VER >= 26
Expand Down
10 changes: 5 additions & 5 deletions libcxx/include/numeric
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,15 @@ template<class T>

// [numeric.sat], saturation arithmetic
template<class T>
constexpr T add_sat(T x, T y) noexcept; // freestanding, Since C++26
constexpr T saturating_add(T x, T y) noexcept; // freestanding, Since C++26
template<class T>
constexpr T sub_sat(T x, T y) noexcept; // freestanding, Since C++26
constexpr T saturating_sub(T x, T y) noexcept; // freestanding, Since C++26
template<class T>
constexpr T mul_sat(T x, T y) noexcept; // freestanding, Since C++26
constexpr T saturating_mul(T x, T y) noexcept; // freestanding, Since C++26
template<class T>
constexpr T div_sat(T x, T y) noexcept; // freestanding, Since C++26
constexpr T saturating_div(T x, T y) noexcept; // freestanding, Since C++26
template<class T, class U>
constexpr T saturate_cast(U x) noexcept; // freestanding, Since C++26
constexpr T saturating_cast(U x) noexcept; // freestanding, Since C++26

} // std

Expand Down
4 changes: 2 additions & 2 deletions libcxx/include/version
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ __cpp_lib_remove_cvref 201711L <type_traits>
__cpp_lib_result_of_sfinae 201210L <functional> <type_traits>
__cpp_lib_robust_nonmodifying_seq_ops 201304L <algorithm>
__cpp_lib_sample 201603L <algorithm>
__cpp_lib_saturation_arithmetic 202311L <numeric>
__cpp_lib_saturation_arithmetic 202603L <numeric>
__cpp_lib_scoped_lock 201703L <mutex>
__cpp_lib_semaphore 201907L <semaphore>
__cpp_lib_senders 202406L <execution>
Expand Down Expand Up @@ -612,7 +612,7 @@ __cpp_lib_void_t 201411L <type_traits>
# define __cpp_lib_ratio 202306L
// # define __cpp_lib_rcu 202306L
# define __cpp_lib_reference_wrapper 202403L
# define __cpp_lib_saturation_arithmetic 202311L
# define __cpp_lib_saturation_arithmetic 202603L
// # define __cpp_lib_senders 202406L
// # define __cpp_lib_smart_ptr_owner_equality 202306L
# define __cpp_lib_span_at 202311L
Expand Down
10 changes: 5 additions & 5 deletions libcxx/modules/std/numeric.inc
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ export namespace std {

#if _LIBCPP_STD_VER >= 26
// [numeric.sat], saturation arithmetic
using std::add_sat;
using std::div_sat;
using std::mul_sat;
using std::saturate_cast;
using std::sub_sat;
using std::saturating_add;
using std::saturating_cast;
using std::saturating_div;
using std::saturating_mul;
using std::saturating_sub;
#endif

} // namespace std
10 changes: 5 additions & 5 deletions libcxx/test/libcxx/numerics/nodiscard.verify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ void test() {
// clang-format off
#if TEST_STD_VER >= 26
// [numeric.sat]
std::add_sat(94, 82); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
std::sub_sat(94, 82); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
std::mul_sat(94, 82); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
std::div_sat(94, 82); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
std::saturate_cast<signed int>(49); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
std::saturating_add(94, 82); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
std::saturating_sub(94, 82); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
std::saturating_mul(94, 82); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
std::saturating_div(94, 82); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
std::saturating_cast<signed int>(49); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
#endif // TEST_STD_VER >= 26
// clang-format on

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@
# ifndef __cpp_lib_saturation_arithmetic
# error "__cpp_lib_saturation_arithmetic should be defined in c++26"
# endif
# if __cpp_lib_saturation_arithmetic != 202311L
# error "__cpp_lib_saturation_arithmetic should have the value 202311L in c++26"
# if __cpp_lib_saturation_arithmetic != 202603L
# error "__cpp_lib_saturation_arithmetic should have the value 202603L in c++26"
# endif

#endif // TEST_STD_VER > 23
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7782,8 +7782,8 @@
# ifndef __cpp_lib_saturation_arithmetic
# error "__cpp_lib_saturation_arithmetic should be defined in c++26"
# endif
# if __cpp_lib_saturation_arithmetic != 202311L
# error "__cpp_lib_saturation_arithmetic should have the value 202311L in c++26"
# if __cpp_lib_saturation_arithmetic != 202603L
# error "__cpp_lib_saturation_arithmetic should have the value 202603L in c++26"
# endif

# if !defined(_LIBCPP_VERSION) || _LIBCPP_HAS_THREADS
Expand Down

This file was deleted.

Loading
Loading