#include <iostream>
namespace utils{
void printf(const char* format){
std::cout << format;
}
template<typename T, typename ... Args>
void printf(const char* format, T value, Args ... args){
for ( ; *format != '\0'; format++ ) {
if ( *format == '%' ) {
std::cout << value;
printf(format + 1, args ... );
return;
}
std::cout << *format;
}
}
template<typename T, typename ... Args>
void printf(const std::string& format, T value, Args ... args){
printf(format.c_str(), value, args...);
}
}
int main(){
utils::printf('% world% %\n', "Hello", '!', 2019);
}
Comments
0 B
|0 👍
/0 👎
0 B
|0 👍
/0 👎