On Saturday, 16 November 2013 at 23:55:47 UTC, Jonathan M Davis wrote:

If you're dealing with variadic arguments, then making the file and line number be template arguments is really your only solution. However, I must warn you that that will result in a new template instantation _every_ time that you use error, because the file and line number are always going to be different unless you call the function multiple times on the same line). So, this approach is pretty much guaranteed to generate template bloat. That may be acceptable, but I'd personally suggest trying to find a different way to go about solving the problem unless error is not going to be called very often - e.g. force the caller to call format when creating the message rather than supporting
variadic arguments directly in error.

- Jonathan M Davis

Something I'm wondering: if one were to split the implementation along these lines:


void error (string file = __FILE__, size_t line = __LINE__, Args...) (string msg, Args args) {
    errorImpl(file, line, msg, args);
}

void errorImpl (Args...) (string file, size_t line, string msg, Args args) {...}


What are the chances of the middle-man function being inlined, thus cutting down on template bloat in the final product? I should hope it would be practically guaranteed.

Reply via email to