idealvin / coost

A tiny boost library in C++11.
Other
3.91k stars 558 forks source link

fastream 在不同平台测试比 snprintf 快 10~30 倍左右, 但是如何快速格式化字符串为faststring 类呢 #329

Closed youyuanshanren closed 12 months ago

youyuanshanren commented 1 year ago

经常遇到的是 void output(const char* format, ...) 这种类型的函数,含有不定参数,如果不使用vsnprintf 这类的参数,如何快速转换为faststring 或者 fastream 类型呢

idealvin commented 1 year ago

fastring::cat()fastream::cat() 可以接受任意数量的参数

cailei77 commented 1 year ago

cat()函数似乎不能格式化字符串啊?如何能够做到类似sprintf的功能呢?

idealvin commented 12 months ago

cat 随便拼接,要啥格式化

fastring s;
s << "hello " << 23;
s.cat("hello ", 23, ' ', false);