sprit(文字列の分割)

概要:文字列の分割
ソース:split.hpp (ASCII CR/LF)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
template< class TChar, class TTraits, class TAllocator, class TOutputIterator > inline
TOutputIterator split(
    const std::basic_string<TChar, TTraits, TAllocator>& S_,
    const std::basic_string<TChar, TTraits, TAllocator>& D_,
    TOutputIterator O_
) {
    typedef std::basic_string<TChar, TTraits, TAllocator> string_type;
    string_type::size_type F_ = 0;
    string_type::size_type L_ = S_.find(D_, F_);
    while (L_ != string_type::npos) {
        *O_++ = string_type(S_, F_, L_ - F_);
        F_ = L_ + D_.length();
        L_ = S_.find(D_, F_);
    }
    *O_++ = string_type(S_, F_, S_.length() - F_);
    return O_;
}