[libcxx-commits] [libcxx] [libcxx] adds ranges::fold_left_with_iter and ranges::fold_left (PR #75259)

via libcxx-commits libcxx-commits at lists.llvm.org
Thu Dec 14 15:37:38 PST 2023


================
@@ -87,4 +89,15 @@ void test() {
   std::ranges::unique(iter, iter); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
   std::ranges::upper_bound(range, 1); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
   std::ranges::upper_bound(iter, iter, 1); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+
+#if TEST_STD_VER >= 23
+  std::ranges::fold_left(range, 0, std::plus());
+  // expected-warning at -1{{ignoring return value of function declared with 'nodiscard' attribute}}
----------------
EricWF wrote:

I don't think this is correct. There are many valid ways to use this function without inspecting the result.

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


More information about the libcxx-commits mailing list