[libcxx-commits] [PATCH] D154358: [libc++] Use this in lamba capture in <latch>

Edo via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Jul 3 08:33:56 PDT 2023


diamante0018 created this revision.
Herald added a project: All.
diamante0018 requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

I noticed as I skimmed through <latch> that "&" seemed to be used in a situation where perhaps it's not the best option.

Other libc++ modules make use of [this] when calling functions from the same class (example: https://github.com/llvm/llvm-project/blob/70617a1a2389a1abe6151d52dc749fb5f7755439/libcxx/include/semaphore#L106)

I believe that much like in the other library modules [this] would be the appropriate lambda capture specifier here as well.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154358

Files:
  libcxx/include/latch


Index: libcxx/include/latch
===================================================================
--- libcxx/include/latch
+++ libcxx/include/latch
@@ -96,7 +96,7 @@
     inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
     void wait() const
     {
-        __cxx_atomic_wait(&__a_.__a_, [&]() -> bool {
+        __cxx_atomic_wait(&__a_.__a_, [this]() -> bool {
             return try_wait();
         });
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154358.536782.patch
Type: text/x-patch
Size: 423 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230703/56bea849/attachment.bin>


More information about the libcxx-commits mailing list