How to create a wrapper on printf?
<p>I want to write an conditional printf, something like this</p>

<pre><code>class ConditionalPrintf
{
public:
    ConditionalPrintf(bool print)
        : print_(print)
    {}

   void printf(int x, double y, char b, const char* format, ...) const
   {
        // use x, y and b

        va_list argptr;
        va_start(argptr, format);

        if (print_)
            printf(format, argptr);

        va_end(argptr);
   }

private:
   bool print_;
};
</code></pre>

<p>But it prints garbage. Is there anything wrong? May implicit this parameter change things?</p>

<p>Also, if this isn't good idea whatsoever, what other solutions are there? I just don't want to write <code>if (print) printf(...)</code> billion times.</p>