[libcxx-commits] [PATCH] D142909: [libc++] Addresses LWG3755.

Mark de Wever via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jan 31 11:08:14 PST 2023


This revision was automatically updated to reflect the committed changes.
Closed by commit rGf02c9e6f26fc: [libc++] Addresses LWG3755. (authored by Mordante).

Changed prior to commit:
  https://reviews.llvm.org/D142909?vs=493336&id=493682#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142909/new/

https://reviews.llvm.org/D142909

Files:
  libcxx/docs/Status/Cxx2bIssues.csv
  libcxx/include/__ranges/zip_view.h
  libcxx/test/libcxx/ranges/range.adaptors/range.adaptor.tuple/tuple-for-each.pass.cpp


Index: libcxx/test/libcxx/ranges/range.adaptors/range.adaptor.tuple/tuple-for-each.pass.cpp
===================================================================
--- /dev/null
+++ libcxx/test/libcxx/ranges/range.adaptors/range.adaptor.tuple/tuple-for-each.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <ranges>
+
+// template<class F, class Tuple>
+// constexpr void tuple-for-each(F&& f, Tuple&& t) { // exposition only
+
+// LWG3755 tuple-for-each can call user-defined operator,
+
+#include <ranges>
+#include <tuple>
+#include <cstdlib>
+
+struct Evil {
+  void operator,(Evil) { std::abort(); }
+};
+
+int main(int, char**) {
+  std::tuple<int, int> t;
+  std::ranges::__tuple_for_each([](int) { return Evil{}; }, t);
+
+  return 0;
+}
Index: libcxx/include/__ranges/zip_view.h
===================================================================
--- libcxx/include/__ranges/zip_view.h
+++ libcxx/include/__ranges/zip_view.h
@@ -77,7 +77,9 @@
 template <class _Fun, class _Tuple>
 _LIBCPP_HIDE_FROM_ABI constexpr void __tuple_for_each(_Fun&& __f, _Tuple&& __tuple) {
   std::apply(
-      [&]<class... _Types>(_Types&&... __elements) { (std::invoke(__f, std::forward<_Types>(__elements)), ...); },
+      [&]<class... _Types>(_Types&&... __elements) {
+        (static_cast<void>(std::invoke(__f, std::forward<_Types>(__elements))), ...);
+      },
       std::forward<_Tuple>(__tuple));
 }
 
Index: libcxx/docs/Status/Cxx2bIssues.csv
===================================================================
--- libcxx/docs/Status/Cxx2bIssues.csv
+++ libcxx/docs/Status/Cxx2bIssues.csv
@@ -212,7 +212,7 @@
 "`3751 <https://wg21.link/LWG3751>`__","Missing feature macro for ``flat_set``", "November 2022","","","|flat_containers|"
 "`3753 <https://wg21.link/LWG3753>`__","Clarify entity vs. freestanding entity", "November 2022","","",""
 "`3754 <https://wg21.link/LWG3754>`__","Class template expected synopsis contains declarations that do not match the detailed description", "November 2022","|Nothing to do|","",""
-"`3755 <https://wg21.link/LWG3755>`__","``tuple-for-each`` can call ``user-defined`` ``operator,``", "November 2022","","",""
+"`3755 <https://wg21.link/LWG3755>`__","``tuple-for-each`` can call ``user-defined`` ``operator,``", "November 2022","|Complete|","17.0",""
 "`3757 <https://wg21.link/LWG3757>`__","What's the effect of ``std::forward_like<void>(x)``?", "November 2022","","",""
 "`3759 <https://wg21.link/LWG3759>`__","``ranges::rotate_copy`` should use ``std::move``", "November 2022","","","|ranges|"
 "`3760 <https://wg21.link/LWG3760>`__","``cartesian_product_view::iterator``'s ``parent_`` is never valid", "November 2022","","","|ranges|"


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142909.493682.patch
Type: text/x-patch
Size: 3086 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230131/f42384a2/attachment-0001.bin>


More information about the libcxx-commits mailing list