[libcxx-commits] [libcxx] [libcxx] Add LWG4135: The helper lambda of std::erase for list should specify return type as bool (PR #128358)

Mark de Wever via libcxx-commits libcxx-commits at lists.llvm.org
Sat Feb 22 07:09:52 PST 2025


================
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+#include <forward_list>
+struct Bool {
+  Bool() = default;
+  Bool(const Bool&) = delete;
+  operator bool() const { return true; }
+};
+
+struct Int {
+  Bool& operator==(Int) const {
+    static Bool b;
+    return b;
+  }
+};
+
+int main() {
+  std::forward_list<Int> l;
+  std::erase(l, Int{});
+}
----------------
mordante wrote:

Some of the platforms we support require this main signature and and explicit return value.
```suggestion
int main(int, char**) {
  std::forward_list<Int> l;
  std::erase(l, Int{});
  
  return 0;
}
```

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


More information about the libcxx-commits mailing list