]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Replace implicit lambda capture of 'this' [PR116964]
authorJonathan Wakely <jwakely@redhat.com>
Fri, 4 Oct 2024 09:44:46 +0000 (10:44 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Fri, 4 Oct 2024 09:53:23 +0000 (10:53 +0100)
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.

libstdc++-v3/include/std/shared_mutex

index 9bf98c0b04056910f902691c5c946c892d63737f..b369a15cc608bda0e729d16fe33be230c0d23b48 100644 (file)
@@ -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;
          }