[libcxx-commits] [libcxx] [libc++][numeric] P4052R0: Renaming saturation arithmetic functions (PR #189574)

Hristo Hristov via libcxx-commits libcxx-commits at lists.llvm.org
Tue Mar 31 07:32:39 PDT 2026


================
@@ -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}}
----------------
H-G-Hristov wrote:

```suggestion
  std::saturating_cast<signed int>(49);      // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
```

https://github.com/llvm/llvm-project/pull/189574


More information about the libcxx-commits mailing list