diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2013-06-25 00:07:15 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2013-06-25 00:07:15 +0900 |
| commit | 2761301dfb6e12fd229f65b49eb28391e49ca671 (patch) | |
| tree | ba79ac33a99e136bfd3ccedaa1928ec38cea416a /src/util.h | |
| parent | 2f6eff3821d11608215292792d0879efeeabe2e3 (diff) | |
Rewrite util::divide
Diffstat (limited to 'src/util.h')
| -rw-r--r-- | src/util.h | 17 |
1 files changed, 6 insertions, 11 deletions
@@ -158,20 +158,15 @@ std::string strip (const std::string& str, const char* chars = DEFAULT_STRIP_CHARSET); template<typename InputIterator> -void divide -(std::pair<std::pair<InputIterator, InputIterator>, - std::pair<InputIterator, InputIterator> >& hp, - InputIterator first, - InputIterator last, - char delim) +std::pair<std::pair<InputIterator, InputIterator>, + std::pair<InputIterator, InputIterator>> +divide(InputIterator first, InputIterator last, char delim) { - InputIterator dpos = std::find(first, last, delim); + auto dpos = std::find(first, last, delim); if(dpos == last) { - hp.first = stripIter(first, last); - hp.second.first = hp.second.second; + return {stripIter(first, last), {last, last}}; } else { - hp.first = stripIter(first, dpos); - hp.second = stripIter(dpos+1, last); + return {stripIter(first, dpos), stripIter(dpos+1, last)}; } } |
