Is there a shorthand for std::lock_guard<std::mutex> lock(m)?
<p>Exactly what the question states.  In C++, ideally 11, but curious about 14 and later too, is there a shorthand syntax for:</p>

<pre><code>std::mutex someMutex;
std::lock_guard&lt;std::mutex&gt; lg(someMutex);
</code></pre>

<p>Ideally something that infers the type of mutex to avoid the refactoring if I ever wanted to change to a <code>std::recursive_mutex</code>.</p>

<p>In other words, a way to do this:</p>

<pre><code>std::mutex someMutex;
std::lock_guard lg(someMutex);
</code></pre>

<p>Or</p>

<pre><code>auto lg = make_lock_guard(someMutex);
</code></pre>

<p>For all the type deduction powers of modern  C++, it just seems awfully redundant to go typing <code>std::lock_guard&lt;std::mutex&gt;</code> every time I want to make one.</p>