title: Is there any implementation of type-safe, compile-time checked printf?
body: <p>I saw many implementation of type-safe printf, but most of them are using exception to raise type errors.</p>
  
  <p>As exercise, I implemented prototype of printf-like formatting using string literals, and it seems to solve all the problems with old, good printf family (except using format read from external source which is always not safe).</p>
  
  <p><strong>Example:</strong></p>
  
  <pre><code>int main(int argc, char* argv[])
  {
      std::cout &lt;&lt; "const char*: %s, std::string: %s\n"_format("ONE", std::string{"TWO"});
      std::cout &lt;&lt; "user defined: %*\n"_format(std::complex&lt;int&gt;{1, 2});
      std::cout &lt;&lt; "hex: 0x%x, int: %d\n"_format(16, 123);
      std::cout &lt;&lt; "double.2: %.2f, double: %f\n"_format(13.123123, 12.1);
  
      std::string s = "p(%d, %d)\n"_format(123, 234);
      std::cout &lt;&lt; s;
  
  //    not yet working
  //    int x, y;
  //    std::cin &gt;&gt; "p(%d, %d)"_format(x, y);
  //    "p(%d, %d)"_format(x, y) = "p(999, 888)";
  }
  </code></pre>
  
  <p>Full, dirty and not complete nor optimized code is  <a href="https://gist.github.com/ziomq1991/509a3a4cbd04e37003e52ee30ac26fea" rel="noreferrer">here</a></p>
  
  <p>Generated <code>.s</code> shows that no text processing is done in runtime, even if variables are not <code>const</code>, but taken for example from <code>argv</code>. Passing wrong variable type, or using argument count cause ugly compilation error, which could be improved with static asserts or concepts.</p>
  
  <p>This is only exercise, and the question is: Is it any library, which supports such constructions, and why such approach is not part of c++ standard?</p>