summaryrefslogtreecommitdiff
path: root/src/util.h
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2013-06-25 00:07:15 +0900
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2013-06-25 00:07:15 +0900
commit2761301dfb6e12fd229f65b49eb28391e49ca671 (patch)
treeba79ac33a99e136bfd3ccedaa1928ec38cea416a /src/util.h
parent2f6eff3821d11608215292792d0879efeeabe2e3 (diff)
Rewrite util::divide
Diffstat (limited to 'src/util.h')
-rw-r--r--src/util.h17
1 files changed, 6 insertions, 11 deletions
diff --git a/src/util.h b/src/util.h
index 0f93e0de..352384e7 100644
--- a/src/util.h
+++ b/src/util.h
@@ -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)};
}
}