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

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

c++ 字符串分割函數stringsplit

2019-11-14 11:30:45
字體:
來源:轉載
供稿:網友
/* 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
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 广东省| 南城县| 睢宁县| 老河口市| 浪卡子县| 广西| 固安县| 上高县| 龙南县| 出国| 长乐市| 鄂托克旗| 郴州市| 枣强县| 萍乡市| 隆回县| 吉水县| 石狮市| 高安市| 昂仁县| 沅陵县| 巴塘县| 永泰县| 和顺县| 会同县| 林芝县| 镇康县| 仪征市| 诏安县| 惠安县| 海伦市| 常山县| 多伦县| 安吉县| 新民市| 噶尔县| 噶尔县| 彭阳县| 榆树市| 浮梁县| 漠河县|