I have an assert macros which looks like:
#define ASSERT(condition, ...) \
(condition) ? (void)0 : MyLogFunction(__LINE__, __VA_ARGS__)
MyLogFunction
is a variadic template too:
template<typename... Args>
void MyLogFunction(int line, const Args&... args) {/*code*/}
Everything works well except the case when I don't want to insert additional information into assert call.
So this works nice:
ASSERT(false, "test: %s", "formatted");
But this isn't:
ASSERT(false);
I believe there is a way to handle situation when no variadic args has has been passed into macro call and there is a way to insert something like simple string ""
instead of __VA_ARGS__