Let us consider the following function:
static void Print(const Type& type, const std::string& message, const std::string& variable) {
Log(type, message + ": " + variable);
}
I'd like it to pass arbitrary number of variables (I mean std::string & variable - this holds a variable name) and then send them via Log() function together and for this reason, I've considered using template variadic function (an overloaded Print()). I'd define it like this:
template <typename Arg, typename ...Args)
static void Print(const Type& type, const std::string& message,
const Arg& arg, const Args&... args);
and then:
Print(type, message, args...);
Log(type, message + ": " + arg);
Just an idea, this would work most likely like this:
args...would be passed andPrint()function would be called recursively until there's no arguments left,- but at the same time,
Log()function would be called which would basically log it every time.
What I would need to do is to somehow remember arg value but it would require calling Print() with an additional argument and I don't really like this idea. Do you have any other clues?
Print, then everything else is handled recursively by, say,PrintImpl.