c++ - boost::format() 输出运算符

标签 c++ string-formatting boost-format

我需要像 cout 那样编写将通过运算符接受 boost::format() 的类:

cout << boost::format("some string; some param = %d\n") % someValue;

算子的参数必须是什么类型? 这样类将像这样声明:

class Output
{
    Output& operator<<(... format);
}
int main()
{
    Output output;
    output << boost::format("...");
}

谢谢。

最佳答案

boost::format 就是你想要的类型。它有一个 str() 成员来获取 std::string。

关于c++ - boost::format() 输出运算符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5133265/

相关文章:

C++ ostream 引用

c++ - 通过指针访问非静态类成员函数的说明

R - 带有周-年 : week is lost when converting to Date format 的字符串

c++ - 如何累积持续时间

c++ - 在 boost::lambda 中使用 boost::format

C++ 访问者模式处理模板化字符串类型?

c++ - 无法打印 signed int 类型的大小

java - 如何使这些方法正确返回?

python - 为什么Python格式的迷你语言的所有例子中都有一个 ':'?