Skip to content

Instantly share code, notes, and snippets.

@SeanCline
Last active August 29, 2015 14:01
Show Gist options
  • Save SeanCline/4fff33f95b31708fa5e4 to your computer and use it in GitHub Desktop.
Save SeanCline/4fff33f95b31708fa5e4 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <string>
#include <utility>
#include <boost/format.hpp>
template<typename T>
boost::format& apply_format_args(boost::format& form, T&& t)
{
return form % std::forward<T>(t);
}
template<typename T, typename ...Ts>
boost::format& apply_format_args(boost::format& form, T&& t, Ts&&... ts)
{
return apply_format_args(form % std::forward<T>(t), std::forward<Ts>(ts)...);
}
template<typename ...Ts>
void print(const std::string& formatStr, Ts&&... args)
{
std::cout << apply_format_args(boost::format(formatStr), std::forward<Ts>(args)...) << std::endl;
}
int main() {
print("%d %d %s", 1, 2, "hello world");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment