X-Git-Url: http://xvm.mit.edu/gitweb/invirt/third/libt4.git/blobdiff_plain/be7cf844f59fa483423724e8e4b5e663e5b88ddd..e478ac59e66e89cbc174e781ac715c8644539947:/types.h diff --git a/types.h b/types.h index cdb629a..0897649 100644 --- a/types.h +++ b/types.h @@ -48,8 +48,6 @@ using std::setfill; using std::setprecision; using std::ostream; using std::istream; -using std::ostream_iterator; -using std::istream_iterator; using std::ios; #include @@ -133,12 +131,13 @@ template constexpr inline E to_enum(enum_type_t value) noexcept { template inline typename enable_if::value, string>::type implode(const C & v, string delim=" ") { - if (v.begin() == v.end()) + auto i=v.cbegin(), end=v.cend(); + if (i == end) return string(); ostringstream oss; - auto last = prev(v.end()); - copy(v.begin(), last, ostream_iterator(oss, delim.c_str())); - oss << *last; + oss << *i++; + while (i != end) + oss << delim << *i++; return oss.str(); } @@ -147,7 +146,7 @@ inline vector explode(const string &s, string delim=" ") { size_t start = 0, end = 0; while ((end = s.find(delim, start)) != string::npos) { out.push_back(s.substr(start, end - start)); - start = end + 1; + start = end + delim.size(); } out.push_back(s.substr(start)); return out;