format.hpp 536 B

1234567891011121314151617181920212223
  1. #include "boost/format.hpp"
  2. #include <iostream>
  3. template<class TFirst>
  4. void string_format(boost::format& fmt, TFirst&& first)
  5. {
  6. fmt% first;
  7. }
  8. template<class TFirst, class... TOther>
  9. void string_format(boost::format& fmt, TFirst&& first, TOther&&... other)
  10. {
  11. fmt% first;
  12. string_format(fmt, other...);
  13. }
  14. template<class TFirst, class... TOther>
  15. std::string string_format(const char* format, TFirst&& first, TOther&&... other)
  16. {
  17. boost::format fmt(format);
  18. string_format(fmt, first, other...);
  19. return fmt.str();
  20. }