How to aliase a function with variable number of arguments?
<p>I have a method in a class with this signature:</p>

<pre><code>void addMessage_( std::string appender, LogLevel level /*= LOGLEVEL_INFO*/, char* msg, ... );
</code></pre>

<p>I want to create 'alias' of this method in this way:</p>

<pre><code>void debugMsg( std::string appender, char* msg, ... ){
    addMessage(appender, LOGLEVEL_DEBUG, msg, ...);
}
</code></pre>

<p>My question is: do I need to expand the args to call the addMessage method? I don't want to replicate the code I each utility method, but I don't want to waste performance. What is the best solution?</p>

<p>Solved: I let my solution as a documentation:</p>

<pre><code>void DEBUG_MSG(std::string appender, char* msg, ...){
    va_list argptr;
    va_start(argptr,msg);
    addMessage_(appender, LOGLEVEL_DEBUG, msg, argptr);
    va_end(argptr);
}
</code></pre>

<p>And the addMessage_ method:</p>

<pre><code>    void CGlobalLog::addMessage_( std::string appender, LogLevel level, char* msg, va_list args ){

    int     len;
    char    *buffer;

    len = _vscprintf( msg, args ) // _vscprintf doesn't count
        + 1; // terminating '\0'

    buffer = (char*)malloc( len * sizeof(char) );

    vsprintf( buffer, msg, args ); // C4996
    // Note: vsprintf is deprecated; consider using vsprintf_s instead
    addMessage(buffer,appender,level);

    free( buffer );
}
</code></pre>

<p>Thanks!</p>
