一个很好的例子升压::算法::加盟 [英] A good example for boost::algorithm::join
本文介绍了一个很好的例子升压::算法::加盟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我最近想用<一个href=\"http://www.boost.org/doc/libs/1_41_0/doc/html/string_algo/reference.html#header.boost.algorithm.string.join_hpp\">提高::算法::加入但我找不到任何使用的例子,我不想投入大量的时间学习了Boost库的范围仅仅使用这一功能。
任何人都可以提供如何使用加入字符串容器上的好榜样?谢谢你。
解决方案
的#include&LT;提升/算法/串/ join.hpp&GT;
#包括LT&;矢量&GT;
#包括LT&;&iostream的GT;INT主(INT,CHAR **)
{
的std ::矢量&lt;标准::字符串&GT;清单;
list.push_back(你好);
list.push_back(世界!); 标准::字符串连接=的boost ::算法::加入(名单,);
性病::法院LT&;&LT;加入&LT;&LT;的std :: ENDL;
}
输出:
你好,世界!
PS:我不知道的功能,这将有助于我在未来;)
I recently wanted to use boost::algorithm::join but I couldn't find any usage examples and I didn't want to invest a lot of time learning the Boost Range library just to use this one function.
Can anyone provide a good example of how to use join on a container of strings? Thanks.
解决方案
#include <boost/algorithm/string/join.hpp>
#include <vector>
#include <iostream>
int main(int, char **)
{
std::vector<std::string> list;
list.push_back("Hello");
list.push_back("World!");
std::string joined = boost::algorithm::join(list, ", ");
std::cout << joined << std::endl;
}
Output:
Hello, World!
PS: I didn't know that function, it will help me in the future ;)
这篇关于一个很好的例子升压::算法::加盟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文