Includes cleanups
[invirt/third/libt4.git] / types.h
diff --git a/types.h b/types.h
index cdb629a..d2d5411 100644 (file)
--- a/types.h
+++ b/types.h
@@ -1,6 +1,8 @@
 #ifndef types_h
 #define types_h
 
+#include <sys/types.h>
+
 #include <algorithm>
 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 <limits>
@@ -61,6 +61,12 @@ using std::list;
 #include <map>
 using std::map;
 
+#include <memory>
+using std::enable_shared_from_this;
+using std::make_shared;
+using std::shared_ptr;
+using std::unique_ptr;
+
 #include <mutex>
 using std::mutex;
 using lock = std::unique_lock<std::mutex>;
@@ -133,12 +139,13 @@ template<typename E> constexpr inline E to_enum(enum_type_t<E> value) noexcept {
 template <class C>
 inline typename enable_if<is_const_iterable<C>::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<typename C::value_type>(oss, delim.c_str()));
-    oss << *last;
+    oss << *i++;
+    while (i != end)
+        oss << delim << *i++;
     return oss.str();
 }
 
@@ -147,7 +154,7 @@ inline vector<string> 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;