title: Deadlock avoidance using scoped_lock
body: <p>I'm testing out some example code in the Galowicz C++17 book, listed below:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;mutex&gt;
  #include &lt;thread&gt;
  
  using namespace std;
  using namespace chrono_literals;
  
  mutex mut_a;
  mutex mut_b;
  
  static void deadlock_func_1() {
    cout &lt;&lt; "bad f1 acquiring mutex A..." &lt;&lt; endl;
    lock_guard&lt;mutex&gt; la{mut_a};
    this_thread::sleep_for(100ms);
    cout &lt;&lt; "bad f1 acquiring mutex B..." &lt;&lt; endl;
    lock_guard&lt;mutex&gt; lb{mut_b};
    cout &lt;&lt; "bad f1 got both mutexes." &lt;&lt; endl;
  }
  static void deadlock_func_2() {
    cout &lt;&lt; "bad f2 acquiring mutex B..." &lt;&lt; endl;
    lock_guard&lt;mutex&gt; lb{mut_b};
    this_thread::sleep_for(100ms);
    cout &lt;&lt; "bad f2 acquiring mutex A..." &lt;&lt; endl;
    lock_guard&lt;mutex&gt; la{mut_a};
    cout &lt;&lt; "bad f2 got both mutexes." &lt;&lt; endl;
  }
  
  static void sane_func_1() {
    scoped_lock l{mut_a, mut_b};
    cout &lt;&lt; "sane f1 got both mutexes.:" &lt;&lt; endl;
  }
  static void sane_func_2() {
    scoped_lock l{mut_b, mut_a};
    cout &lt;&lt; "sane f2 got both mutexes." &lt;&lt; endl;
  }
  
  int main() {
    {
      thread t1{sane_func_1};
      thread t2{sane_func_2};
      t1.join();
      t2.join();
    }
  }
  </code></pre>
  
  <p>I'm getting E0441, C2955, and C2514 errors on the <code>scoped_lock</code> lines within <code>sane_func_1()</code> and <code>sane_func_2()</code>. The compiler is complaining about argument lists and constructors for these 2 lines. I'm hoping it's just a syntax error I overlooked or something that's fallen out of the appropriate scope.</p>