[PATCH] Simplify std::scoped_lock destructor

Jonathan Wakely jwakely@redhat.com
Wed Jun 12 14:54:00 GMT 2019


	* include/std/mutex (scoped_lock::~scoped_lock()): Use fold
	expression.

Thanks to Lars for pointing out this could be simplified.

Tested x86_64-linux, committed to trunk.

-------------- next part --------------
commit 7445abf1ee5e14e644efd0533fff9e0c125b1d2c
Author: redi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Wed Jun 12 14:52:06 2019 +0000

    Simplify std::scoped_lock destructor
    
            * include/std/mutex (scoped_lock::~scoped_lock()): Use fold
            expression.
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@272187 138bc75d-0d04-0410-961f-82ee72b054a4

diff --git a/libstdc++-v3/include/std/mutex b/libstdc++-v3/include/std/mutex
index ca2c669db9a..981b6725f7c 100644
--- a/libstdc++-v3/include/std/mutex
+++ b/libstdc++-v3/include/std/mutex
@@ -576,11 +576,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       { } // calling thread owns mutex
 
       ~scoped_lock()
-      {
-	std::apply([](_MutexTypes&... __m) {
-	  char __i[] __attribute__((__unused__)) = { (__m.unlock(), 0)... };
-	}, _M_devices);
-      }
+      { std::apply([](auto&... __m) { (__m.unlock(), ...); }, _M_devices); }
 
       scoped_lock(const scoped_lock&) = delete;
       scoped_lock& operator=(const scoped_lock&) = delete;


More information about the Libstdc++ mailing list