https://gcc.gnu.org/g:f135278f559914c0336cd8ad0af0deac2a0c86fd

commit r15-4058-gf135278f559914c0336cd8ad0af0deac2a0c86fd
Author: Jonathan Wakely <jwak...@redhat.com>
Date:   Fri Oct 4 10:44:46 2024 +0100

    libstdc++: Replace implicit lambda capture of 'this' [PR116964]
    
    C++20 deprecates implicit capture of 'this', so change [=] to [this] for
    all lambda expressions in <shared_mutex>. This only shows up on targets
    where _GLIBCXX_USE_PTHREAD_RWLOCK_T is not defined, as we have an
    alternative implementation of shared mutexes in that case.
    
    libstdc++-v3/ChangeLog:
    
            PR libstdc++/116964
            * include/std/shared_mutex (__shared_mutex_cv): Use [this] for
            lambda captures.
            (shared_timed_mutex) [!_GLIBCXX_USE_PTHREAD_RWLOCK_T]: Likewise.

Diff:
---
 libstdc++-v3/include/std/shared_mutex | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/libstdc++-v3/include/std/shared_mutex 
b/libstdc++-v3/include/std/shared_mutex
index 9bf98c0b0405..b369a15cc608 100644
--- a/libstdc++-v3/include/std/shared_mutex
+++ b/libstdc++-v3/include/std/shared_mutex
@@ -332,10 +332,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     {
       unique_lock<mutex> __lk(_M_mut);
       // Wait until we can set the write-entered flag.
-      _M_gate1.wait(__lk, [=]{ return !_M_write_entered(); });
+      _M_gate1.wait(__lk, [this]{ return !_M_write_entered(); });
       _M_state |= _S_write_entered;
       // Then wait until there are no more readers.
-      _M_gate2.wait(__lk, [=]{ return _M_readers() == 0; });
+      _M_gate2.wait(__lk, [this]{ return _M_readers() == 0; });
     }
 
     bool
@@ -367,7 +367,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     lock_shared()
     {
       unique_lock<mutex> __lk(_M_mut);
-      _M_gate1.wait(__lk, [=]{ return _M_state < _S_max_readers; });
+      _M_gate1.wait(__lk, [this]{ return _M_state < _S_max_readers; });
       ++_M_state;
     }
 
@@ -690,13 +690,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       {
        unique_lock<mutex> __lk(_M_mut);
        if (!_M_gate1.wait_until(__lk, __abs_time,
-                                [=]{ return !_M_write_entered(); }))
+                                [this]{ return !_M_write_entered(); }))
          {
            return false;
          }
        _M_state |= _S_write_entered;
        if (!_M_gate2.wait_until(__lk, __abs_time,
-                                [=]{ return _M_readers() == 0; }))
+                                [this]{ return _M_readers() == 0; }))
          {
            _M_state ^= _S_write_entered;
            // Wake all threads blocked while the write-entered flag was set.
@@ -716,7 +716,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       {
        unique_lock<mutex> __lk(_M_mut);
        if (!_M_gate1.wait_until(__lk, __abs_time,
-                                [=]{ return _M_state < _S_max_readers; }))
+                                [this]{ return _M_state < _S_max_readers; }))
          {
            return false;
          }

Reply via email to