template <typename Outit> int split(const std::wstring &pattern, const std::wstring &subject, Outit Dest){ std::wstring::size_type pattern_length = pattern.length(); std::wstring::size_type beginpos = 0; std::wstring::size_type endpos = subject.find(pattern); while (endpos != std::wstring::npos){ *Dest = subject.substr(beginpos, endpos-beginpos); beginpos = endpos + pattern_length; endpos = subject.find(pattern, beginpos); } *Dest = subject.substr(beginpos); return 0; }
필요 함수
std::list<std::wstring> result; split( L"\n", tmpStr, back_inserter(result)); // 구분자: \n, 원본문자열 tmpStr for( auto i=result.begin(); i != result.end(); i++){ std::wstring str = (*i); }
실제 사용하는곳
답글 남기기