Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Log( const std::string& str )
- {
- std::cout << str;
- }
- // http://en.wikipedia.org/wiki/Variadic_templates
- template< typename T, typename... Args >
- void Log( const std::string& str, T value, Args... args )
- {
- for ( auto it = str.begin(); it != str.end(); ++it )
- {
- size_t dist = std::distance( str.begin(), it );
- char cc = ( * it );
- if ( dist >= str.size() - 1 )
- {
- std::cout << cc;
- break;
- }
- char nc = ( * ( it + 1 ) );
- if ( cc == '%' and nc != '%' )
- {
- std::cout << value;
- Log( str.substr( dist + 2 ), args... );
- return;
- }
- std::cout << cc;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement