|
|
@ -5,8 +5,7 @@ |
|
|
|
#include <exception> |
|
|
|
#include <exception> |
|
|
|
#include <algorithm> |
|
|
|
#include <algorithm> |
|
|
|
#include <cctype> |
|
|
|
#include <cctype> |
|
|
|
|
|
|
|
namespace Bk { |
|
|
|
// base case of recursion, no more arguments
|
|
|
|
|
|
|
|
void format_impl(std::stringstream& ss, const char* format) {
|
|
|
|
void format_impl(std::stringstream& ss, const char* format) {
|
|
|
|
while (*format) { |
|
|
|
while (*format) { |
|
|
|
if (*format == '%' && *++format != '%') // %% == % (not a format directive)
|
|
|
|
if (*format == '%' && *++format != '%') // %% == % (not a format directive)
|
|
|
@ -53,3 +52,4 @@ std::string format(const char* fmt, Args... args) { |
|
|
|
format_impl(ss, fmt, args...); |
|
|
|
format_impl(ss, fmt, args...); |
|
|
|
return ss.str(); |
|
|
|
return ss.str(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|