[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 17:40:08 PST 2023


================
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 LIBCXX_TEST_FOLD_REQUIREMENTS_H
+#define LIBCXX_TEST_FOLD_REQUIREMENTS_H
+
+#include <cstddef>
+
+// FIXME(cjdb): deduplicate
+struct bad_iterator_category {
+  using value_type        = int;
+  using difference_type   = std::ptrdiff_t;
+  using iterator_category = void;
+
+  value_type operator*() const;
+
+  bad_iterator_category& operator++();
+  void operator++(int);
+};
+
+struct non_movable {
+  non_movable()              = default;
+  non_movable(non_movable&&) = delete;
+};
+
+struct copyable_non_movable {
+  copyable_non_movable(int);
+  copyable_non_movable(copyable_non_movable&&) = delete;
+  copyable_non_movable(copyable_non_movable const&);
+
+  friend int operator+(copyable_non_movable const&, non_movable const&);
+  friend int operator+(non_movable const&, copyable_non_movable const&);
+
+  friend copyable_non_movable const& operator-(int, copyable_non_movable const&);
----------------
EricWF wrote:

What is this type? 

Are the weird operator overloads  tied to the copyable_non_movable-ness? They seem like entirely separate concerns. 



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


More information about the libcxx-commits mailing list