boost::join

boost::join函数

template< typename SequenceSequenceT, typename Range1T>
	inline typename range_value<SequenceSequenceT>::type 
		join(const SequenceSequenceT& Input,const Range1T& Separator)
  • Input:是一个包含string类型的容器
  • Separator: 一个分隔连接段的字符串
  • 返回值:返回一个连接后的字符串

代码

#include <iostream>
#include <string>
#include <vector>
#include <boost/algorithm/string/join.hpp>

int main()
{
	std::vector<std::string> vct_str;
	vct_str.push_back("123");
	std::string str2 = boost::join(vct_str,",");
	std::cout<<"str2="<<str2<<std::endl;
    
    vct_str.push_back(456);
    std::string str3 = boost::join(vct_str,",");
    std::cout<<"str3="<<str3<<std::endl;
	return 0;
}
[banting@localhost teset]$ g++ -g test4.cpp -L/usr/local/lib -lboost_system -o test4
[banting@localhost teset]$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATHP:/usr/local/lib
[banting@localhost teset]$
str2=123
str3=123,456
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值