core: add sprint(fmt, ...)

Similar to sprintf(), only type-safe.
This commit is contained in:
Avi Kivity
2014-09-10 13:44:10 +03:00
parent 9c2a31bf0f
commit 033f941a1c

View File

@@ -45,4 +45,12 @@ print(const char* fmt, A&&... a) {
return print(bfmt, std::forward<A>(a)...);
}
template <typename... A>
std::string
sprint(const char* fmt, A&&... a) {
boost::format bfmt(fmt);
apply_format(bfmt, std::forward<A>(a)...);
return bfmt.str();
}
#endif /* PRINT_HH_ */