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

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Fri Dec 15 14:26:31 PST 2023


================
@@ -0,0 +1,202 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// Checks that `std::ranges::fold_left`'s requirements are correct.
+
+#include <algorithm>
+#include <concepts>
+#include <functional>
+#include <iterator>
+#include <ranges>
+
+#include "test_range.h"
+#include "test_iterators.h"
+#include "../requirements.h"
+
+// expected-error@*:* 19 {{no matching function for call to object of type 'const __fold_left'}}
+
+void test_iterator() {
+  // expected-note@*:*  10 {{candidate template ignored: constraints not satisfied}}
+  // expected-note@*:*  10 {{candidate function template not viable: requires 3 arguments, but 4 were provided}}
+
+  std::ranges::fold_left(bad_iterator_category(), std::unreachable_sentinel, 0, std::plus());
----------------
philnik777 wrote:

It looks like this test checks SFINAEing bahaviour. If I'm not missing something these should just be test to make sure the functions SFINAE away and not something this specific to the implementation. This looks to me like it's testing the compiler and not the library.

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


More information about the libcxx-commits mailing list