gpt4 book ai didi

c++ - 使用 boost::format 作为符号值打印 bool 值?

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:49:01 69 4
gpt4 key购买 nike

如何使用 boost::format 打印 bool 值作为符号值?

没有 boost::io::group 可以做到吗?似乎预先发送到流的标志得到了重新测试:

#include <iomanip>
#include <iostream>
#include <boost/format.hpp>

int main()
{
std::cout
<< std::boolalpha
<< true << " "
<< boost::format("%1% %2%\n")
% true
% boost::io::group(std::boolalpha, true)
;
}

输出

true 1 true

最佳答案

您可以像这样归档:

#include <iomanip>
#include <iostream>
#include <boost/format.hpp>

int main()
{
std::cout
<< std::boolalpha
<< true << " "
<< boost::format("%1$b %2%\n")
% true
% boost::io::group(std::boolalpha, true)
;
}

关于c++ - 使用 boost::format 作为符号值打印 bool 值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13702304/

69 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com