The following code compiles succesfully but the base function not calling.
#include <iostream>
void tprintf(const char* format)
{
std::cout << "["<<format<<"]";
}
template<typename T, typename... Targs>
void tprintf(const char* format, T value, Targs... Fargs)
{
for (; *format != ''; format++)
{
if (*format == '%')
{
std::cout << value;
tprintf(format + 1, Fargs...);
return;
}
std::cout << *format;
}
}
int main() {
tprintf("% world% %ShouldbeCalledFromBase", "Hello", '!', 123, 444);
}
I am expecting output as:
Hello world! 123[ShouldbeCalledFromBase]
But current output is:
Hello world! 123ShouldbeCalledFromBase
I just want to know why base function not calling.