X-Git-Url: http://xvm.mit.edu/gitweb/invirt/third/libt4.git/blobdiff_plain/be7cf844f59fa483423724e8e4b5e663e5b88ddd..4e881433f37417ccbda89c09ffdf936855d462d4:/types.h diff --git a/types.h b/types.h index cdb629a..ede859f 100644 --- a/types.h +++ b/types.h @@ -1,39 +1,44 @@ #ifndef types_h #define types_h +#include + #include using std::copy; -using std::move; +using std::count_if; +using std::find; using std::max; using std::min; using std::min_element; -using std::find; -using std::count_if; +using std::move; +using std::swap; + +#include +using cond = std::condition_variable; +using std::cv_status; #include -using std::chrono::seconds; -using std::chrono::milliseconds; +using std::chrono::duration_cast; using std::chrono::microseconds; +using std::chrono::milliseconds; using std::chrono::nanoseconds; +using std::chrono::seconds; using std::chrono::steady_clock; using std::chrono::system_clock; -using std::chrono::duration_cast; -using std::chrono::time_point_cast; using std::chrono::time_point; +using std::chrono::time_point_cast; #include using std::exception; #include -using std::ofstream; using std::ifstream; +using std::ofstream; -#ifndef LIBT4_NO_FUNCTIONAL #include +// std::bind conflicts with BIND(2) using std::function; -using std::bind; using std::placeholders::_1; -#endif #include #include @@ -48,8 +53,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,11 +64,16 @@ 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; +using std::weak_ptr; + #include using std::mutex; using lock = std::unique_lock; -using cond = std::condition_variable; -using std::cv_status; #include using std::ostringstream; @@ -133,12 +141,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,13 +156,13 @@ 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; } -#include "lang/verify.h" +#include "verify.h" #include "threaded_log.h" // struct tuple adapter, useful for marshalling @@ -207,4 +216,14 @@ struct pass { template inline pass(Args&&...) {} }; #include "endian.h" +#ifndef __has_attribute +#define __has_attribute(x) 0 +#endif + +#if __has_attribute(noreturn) +#define NORETURN [[noreturn]] +#else +#define NORETURN +#endif + #endif