Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #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);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement