C++ 如何从多个boost::format创建/组合/连接boost::format

C++ 如何从多个boost::format创建/组合/连接boost::format,c++,boost,format,boost-format,C++,Boost,Format,Boost Format,具体如下: boost::format greeting("%s (Greeting)"); boost::format name("%s (Name)"); “greetingwithname”应结合并重用“greeting”和“name”,使其等效于: boost::format greetingwithname("%s (Greeting) %s (Name)"); // looking for solution to like boost::format greetingwithnam

具体如下:

boost::format greeting("%s (Greeting)");
boost::format name("%s (Name)");
“greetingwithname”应结合并重用“greeting”和“name”,使其等效于:

boost::format greetingwithname("%s (Greeting) %s (Name)");
// looking for solution to like boost::format greetingwithname = greeting + name;

如何/从多个boost:format对象创建boost::format对象的最佳方法是什么?

无法连接
boost::format
对象,但正如@sehe所评论的,您可以连接格式字符串,然后从中创建格式对象。

这不是一个选项,而且不能从公共接口实现。廉价的解决方案:连接格式字符串而不是格式化程序对象。谢谢。是的,如果没有简单的解决方案,我将使用std::string并将最终结果应用到格式化程序。