title: {fmt}: always compile-time check format string in function
body: <p>I am trying to create a custom error class, whose constructor creates error message by passing arguments to <code>fmt::format()</code>. I would prefer it to always compile-time check the format string against arguments, without me having to explicitly use <code>FMT_STRING()</code> each time I throw. Something like:</p>
  <pre><code>class Err : public std::exception 
  {
  private:
      std::string m_text;
  public: 
      template &lt;typename S, typename... Args&gt;
      Err(const S&amp; format, Args&amp;&amp;... args) {
          m_text = fmt::format(FMT_STRING(format), args...);
      }
      
      virtual const char* what() const noexcept {return m_text.c_str();}
  };
  
  // ------------------------ 
  
  throw Err(&quot;Error {:d}&quot;, 10);     // works
  throw Err(&quot;Error {:d}&quot;, &quot;abc&quot;);  // cause Compile-time error
  </code></pre>
  <p>With the preceding code I get error on FMT_STRING() macro:</p>
  <pre><code>error C2326: 'Err::{ctor}::&lt;lambda_1&gt;::()::FMT_COMPILE_STRING::operator fmt::v7::basic_string_view&lt;char&gt;(void) const': function cannot access 'format' 
  message : see reference to function template instantiation 'Err::Err&lt;char[11],int&gt;(const S (&amp;),int &amp;&amp;)' being compiled with [ S=char [11] ]
  </code></pre>
  <p>I have very little experience with template programming. How to have make this always compile-time check the format string without explicitly using <code>FMT_STRING()</code> every time?</p>