9 using std::min_element;
14 using std::chrono::seconds;
15 using std::chrono::milliseconds;
16 using std::chrono::microseconds;
17 using std::chrono::nanoseconds;
18 using std::chrono::steady_clock;
19 using std::chrono::system_clock;
20 using std::chrono::duration_cast;
21 using std::chrono::time_point_cast;
22 using std::chrono::time_point;
31 #ifndef LIBT4_NO_FUNCTIONAL
35 using std::placeholders::_1;
48 using std::setprecision;
51 using std::ostream_iterator;
52 using std::istream_iterator;
55 using std::numeric_limits;
65 using lock = std::unique_lock<std::mutex>;
66 using cond = std::condition_variable;
70 using std::ostringstream;
71 using std::istringstream;
86 #include <type_traits>
89 using std::false_type;
91 using std::is_member_function_pointer;
93 using std::underlying_type;
104 template <class A, typename I=void> struct is_iterable : false_type {};
106 template<class A> struct is_iterable<A,
107 decltype(declval<A&>().cbegin(), declval<A&>().cend(), void())
111 inline typename enable_if<is_iterable<C>::value, string>::type
112 implode(const C & v, string delim=" ") {
113 if (v.begin() == v.end())
116 auto last = prev(v.end());
117 copy(v.begin(), last, ostream_iterator<typename C::value_type>(oss, delim.c_str()));
122 inline vector<string> explode(const string &s, string delim=" ") {
124 size_t start = 0, end = 0;
125 while ((end = s.find(delim, start)) != string::npos) {
126 out.push_back(s.substr(start, end - start));
129 out.push_back(s.substr(start));
133 #include "lang/verify.h"
134 #include "threaded_log.h"
136 #define MEMBERS(...) \
137 inline auto _tuple_() -> decltype(tie(__VA_ARGS__)) { return tie(__VA_ARGS__); } \
138 inline auto _tuple_() const -> decltype(tie(__VA_ARGS__)) { return tie(__VA_ARGS__); }
140 #define LEXICOGRAPHIC_OPERATOR(_c_, _op_) \
141 inline bool operator _op_(const _c_ &b) const { return _tuple_() _op_ b._tuple_(); }
143 #define LEXICOGRAPHIC_COMPARISON(_c_) \
144 LEXICOGRAPHIC_OPERATOR(_c_, <) LEXICOGRAPHIC_OPERATOR(_c_, <=) \
145 LEXICOGRAPHIC_OPERATOR(_c_, >) LEXICOGRAPHIC_OPERATOR(_c_, >=) \
146 LEXICOGRAPHIC_OPERATOR(_c_, ==) LEXICOGRAPHIC_OPERATOR(_c_, !=)