Note: This question concerns C++11. The answer to the same question in C++17 (or later revisions) may have changed. For details:
When we want to lock multiple std::mutex
'es, we use std::lock()
. But std::lock()
does not provide RAII feature.
When we want to lock a std::mutex
in RAII way, we use std::lock_guard
. But std::lock_guard
cannot lock multiple std::mutex
'es safely.
Is there any way to take the advantages of both methods, to lock multiple std::mutex
'es in RAII way?