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;
56 using std::numeric_limits;
66 using lock = std::unique_lock<std::mutex>;
67 using cond = std::condition_variable;
71 using std::ostringstream;
72 using std::istringstream;
83 namespace this_thread {
84 using namespace std::this_thread;
92 #include <type_traits>
95 using std::false_type;
97 using std::is_member_function_pointer;
99 using std::underlying_type;
100 using std::enable_if;
101 using std::remove_reference;
112 template <class A, typename I=void> struct is_iterable : false_type {};
114 template<class A> struct is_iterable<A,
115 decltype(declval<A&>().cbegin(), declval<A&>().cend(), void())
119 inline typename enable_if<is_iterable<C>::value, string>::type
120 implode(const C & v, string delim=" ") {
121 if (v.begin() == v.end())
124 auto last = prev(v.end());
125 copy(v.begin(), last, ostream_iterator<typename C::value_type>(oss, delim.c_str()));
130 inline vector<string> explode(const string &s, string delim=" ") {
132 size_t start = 0, end = 0;
133 while ((end = s.find(delim, start)) != string::npos) {
134 out.push_back(s.substr(start, end - start));
137 out.push_back(s.substr(start));
141 #include "lang/verify.h"
142 #include "threaded_log.h"
144 #define MEMBERS(...) \
145 inline auto _tuple_() -> decltype(tie(__VA_ARGS__)) { return tie(__VA_ARGS__); } \
146 inline auto _tuple_() const -> decltype(tie(__VA_ARGS__)) { return tie(__VA_ARGS__); }
148 #define LEXICOGRAPHIC_OPERATOR(_c_, _op_) \
149 inline bool operator _op_(const _c_ &b) const { return _tuple_() _op_ b._tuple_(); }
151 #define LEXICOGRAPHIC_COMPARISON(_c_) \
152 LEXICOGRAPHIC_OPERATOR(_c_, <) LEXICOGRAPHIC_OPERATOR(_c_, <=) \
153 LEXICOGRAPHIC_OPERATOR(_c_, >) LEXICOGRAPHIC_OPERATOR(_c_, >=) \
154 LEXICOGRAPHIC_OPERATOR(_c_, ==) LEXICOGRAPHIC_OPERATOR(_c_, !=)
156 // The following implementation of tuple_indices is redistributed under the MIT
157 // License as an insubstantial portion of the LLVM compiler infrastructure.
159 template <size_t...> struct tuple_indices {};
160 template <size_t S, class IntTuple, size_t E> struct make_indices_imp;
161 template <size_t S, size_t... Indices, size_t E> struct make_indices_imp<S, tuple_indices<Indices...>, E> {
162 typedef typename make_indices_imp<S+1, tuple_indices<Indices..., S>, E>::type type;
164 template <size_t E, size_t... Indices> struct make_indices_imp<E, tuple_indices<Indices...>, E> {
165 typedef tuple_indices<Indices...> type;
167 template <size_t E, size_t S=0> struct make_tuple_indices {
168 typedef typename make_indices_imp<S, tuple_indices<>, E>::type type;