国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

c++ 字符串分割函數stringsplit

2019-11-14 12:01:41
字體:
來源:轉載
供稿:網友
/* stringsplit.hpp sdragonx 2006-06-16 00:43:16 revise  2016.07.18 19:04*/#ifndef STRINGSPLIT_HPP_200606161656#define STRINGSPLIT_HPP_200606161656#include <algorithm>namespace cgl{template<typename char_type, template<typename> class string_type, template<typename> class container>size_t stringsplit(	container< string_type<char_type> >& ls,	typename string_type<char_type>::const_iterator begin,	typename string_type<char_type>::const_iterator end,	char_type spliter,	bool repeat = true){    if(end <= begin)	{    	return 0;	}    typename string_type<char_type>::const_iterator first = begin;    typename string_type<char_type>::const_iterator second;        for( ; first<end; )    {        second = std::find<string_type<char_type>::const_iterator>(first, end, spliter);        if(first == second){            if(repeat)ls.push_back(string_type<char_type>());        }        else{            ls.push_back(string_type<char_type>(first, second));    	}        first = second+1;    }    if(repeat)    {        if(second == end-1){        	ls.push_back(string_type<char_type>());        }    }    return ls.size();}template<typename char_type, template<typename> class string_type, template<typename> class container>size_t stringsplit(	container< string_type<char_type> >& ls,    typename string_type<char_type>::const_iterator begin,    typename string_type<char_type>::const_iterator end,    typename string_type<char_type>::const_iterator spliter_begin,    typename string_type<char_type>::const_iterator spliter_end,    bool repeat = true){    if(end <= begin || spliter_end<=spliter_begin)	{    	return 0;    }    typename string_type<char_type>::const_iterator first = begin;    typename string_type<char_type>::const_iterator second;        for( ; first<end; )    {        second = std::find_first_of<string_type<char_type>::const_iterator>(first, end, spliter_begin, spliter_end);        if(first == second){            if(repeat)ls.push_back(string_type<char_type>());        }        else{        	ls.push_back(string_type<char_type>(first, second));        }        first = second+1;    }    if(repeat)    {        if(second == end-1){        	ls.push_back(string_type<char_type>());        }    }    return ls.size();}template<typename char_type, template<typename> class string_type, template<typename> class container>size_t stringsplit(container< string_type<char_type> > &strs,	const string_type<char_type>& str, char_type spliter, bool repeat = true){    return stringsplit(strs, str.begin(), str.end(), spliter, repeat);}template<typename char_type, template<typename> class string_type, template<typename> class container>size_t stringsplit(container< string_type<char_type> > &strs,	const char_type* str, size_t length, char_type spliter, bool repeat = true){    return stringsplit(strs, str, str+length, spliter, repeat);}template<typename char_type, template<typename> class string_type, template<typename> class container>size_t stringsplit(container< string_type<char_type> > &strs,	const string_type<char_type>& str, const string_type<char_type>& spliter, bool repeat = true){    return stringsplit(strs, str.begin(), str.end(), spliter.begin(), spliter.end(), repeat);}template<typename char_type, template<typename> class string_type, template<typename> class container>size_t stringsplit(container< string_type<char_type> > &strs,	const char_type* str, size_t length, const char_type* spliter, size_t splength, bool repeat = true){    return stringsplit(strs, str, str+length, spliter, spliter+splength, repeat);}}; // end namespace cgl;#endif //STRINGSPLIT_HPP_200606161656
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 锡林郭勒盟| 彰化市| 论坛| 望谟县| 江华| 宜州市| 洪洞县| 大余县| 河曲县| 关岭| 论坛| 六盘水市| 外汇| 特克斯县| 栾城县| 岑巩县| 旌德县| 宁城县| 开化县| 河间市| 南康市| 永寿县| 金门县| 永靖县| 双辽市| 道孚县| 景东| 绥芬河市| 慈利县| 错那县| 治多县| 襄垣县| 根河市| 神木县| 沙雅县| 弥渡县| 高要市| 崇礼县| 灵璧县| 楚雄市| 盘锦市|