替换printf的C++库:tinyformat.h

jopen 12年前

这是一个最小的类型安全替换printf的C++库。

设计目标:

  • Simplicity and minimalism. A single header file to include and distribute with your own projects.
  • Type safety and extensibility for user defined types.
  • Support as many commonly used C99 printf() features as practical without compromising on simplicity.
  • Use variadic templates with C++0x but provide good C++98 support for backward compatibility

示例用法:

std::string weekday = "Wednesday";  const char* month = "July";  long day = 27;  int hour = 14;  int min = 44;    tfm::format(std::cout, "%s, %s %d, %.2d:%.2d\n",              weekday, month, day, hour, min);

项目主页:http://www.open-open.com/lib/view/home/1366531074500