title: c++ pass formatted string as argument to a function
body: <p>OK, this really shouldn't be difficult, but after several attempts, I didn't find any solution.</p>
  
  <p>How can one go about passing a formatted string to a function in 1 line? I want to have a simple method that I can use for logging/debugging purposes, something like this:</p>
  
  <pre><code>void debug(string s){
      if (DEBUG) cerr &lt;&lt; s;
  }
  </code></pre>
  
  <p>I would like to be able to send formatted strings to this function, something like this:</p>
  
  <pre><code>debug("reading %s" % fname);
  </code></pre>
  
  <p>My main goal is to put as much functionality in the debug method so I can make life somewhat easier whenever I want to write stuff to stderr.</p>
  
  <p>printf solutions seem to need a lot of code for simple formatting and boost::format seems to return some vague type that cannot be easily used as an argument without always including some .str() stuff.</p>
  
  <p>Am I too lazy to be a C++ programmer or is there a neat way of accomplishing this goal that I have yet to discover?</p>