title: Can I replace this macro with a constexpr or template?
body: <p>I have a macro that either declares a RAII mutex when I'm compiling a program normally, or skips it for efficiency when I'm compiling in a single-threaded mode (where I set <code>SINGLE_THREADED=1</code>). Obviously I would prefer to not use macros as much as possible. I'm using C++20 (g++) - is there a way to refactor a macro like this to use <code>constexpr</code> or a template instead of <code>#define</code>?</p>
  <p>My current implementation is:</p>
  <pre><code>#ifdef SINGLE_THREADED
  #define READ_LOCK(name, mutex) ({})
  #else
  #define READ_LOCK(name, mutex) folly::SharedMutex::ReadHolder name(mutex);
  #endif
  </code></pre>
  <p>I use it in my code like:</p>
  <pre><code>void foo() {
    READ_LOCK(lg, my_mutex);
    // ....
  }
  </code></pre>