title: Lazy Parameter Evaluation
body: <p>I'm adding a bit amount of tracing and debugging code into a class that I'm refactoring.</p>
  
  <p>I have a <code>Trace</code> object which has some filtering properties and methods <code>bool CanTrace(Level, , TracePropertyList = no_additional_properties)</code> and <code>bool Trace(Level, string, TracePropertyList = no_additional_properties)</code>.</p>
  
  <p>There are already many places in the code where this trace object is used, and the string argument to the <code>Trace</code> method is usually some expression that I would like to avoid evaluating if I'm not going to end up outputting tracing info.</p>
  
  <p>Repeating the chunk of code</p>
  
  <pre><code>if(trace.CanTrace(LEVEL_INFO, some_props))
    trace.Trace(LEVEL_INFO, consume_time().to_str(), some_props);
  </code></pre>
  
  <p>is ugly, and I'd like something shorter.</p>
  
  <p>I was thinking about the macros</p>
  
  <pre><code>#define TRACE_WITH_PROPS(LEVEL,STRING,PROPS) //...
  </code></pre>
  
  <p>and</p>
  
  <pre><code>#define TRACE(LEVEL,STRING) //...
  </code></pre>
  
  <p>Is there a better way to do this? Possibly with templates or C++11? I don't like hiding things from the compiler with defines, and I'm doing my best to remove some macros elsewhere in this codebase.</p>