X-Git-Url: http://xvm.mit.edu/gitweb/invirt/third/libt4.git/blobdiff_plain/be7cf844f59fa483423724e8e4b5e663e5b88ddd..8b9d106fcc61fc84712c97d4db060d8302cc63fd:/types.h diff --git a/types.h b/types.h index cdb629a..d2d5411 100644 --- a/types.h +++ b/types.h @@ -1,6 +1,8 @@ #ifndef types_h #define types_h +#include + #include using std::copy; using std::move; @@ -48,8 +50,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 @@ -61,6 +61,12 @@ using std::list; #include using std::map; +#include +using std::enable_shared_from_this; +using std::make_shared; +using std::shared_ptr; +using std::unique_ptr; + #include using std::mutex; using lock = std::unique_lock; @@ -133,12 +139,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 +154,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;