#include <sys/types.h>
#include <algorithm>
-using std::copy;
-using std::count_if;
-using std::find;
-using std::max;
-using std::min;
-using std::min_element;
-using std::move;
-using std::swap;
#include <condition_variable>
using cond = std::condition_variable;
using std::chrono::time_point_cast;
#include <exception>
-using std::exception;
#include <fstream>
using std::ifstream;
using std::ofstream;
#include <functional>
-// std::bind conflicts with BIND(2)
-using std::function;
-using std::placeholders::_1;
#include <iomanip>
#include <iostream>
-using std::cout;
-using std::cerr;
-using std::endl;
-using std::dec;
-using std::hex;
-using std::left;
-using std::setw;
-using std::setfill;
-using std::setprecision;
-using std::ostream;
-using std::istream;
-using std::ios;
#include <limits>
using std::numeric_limits;
using std::runtime_error;
#include <sstream>
-using std::ostringstream;
-using std::istringstream;
#include <string>
using std::string;
template<typename E> constexpr inline enum_type_t<E> from_enum(E e) noexcept { return (enum_type_t<E>)e; }
template<typename E> constexpr inline E to_enum(enum_type_t<E> value) noexcept { return (E)value; }
+
+template <class A, typename I=void> struct is_tuple_convertible : false_type {};
+
+template<class A> struct is_tuple_convertible<A,
+ decltype(declval<A &>()._tuple_(), void())
+> : true_type {};
+
// string manipulation
template <class A, class B>
-ostream & operator<<(ostream & o, const pair<A,B> & d) {
+std::ostream & operator<<(std::ostream & o, const pair<A,B> & d) {
return o << "<" << d.first << "," << d.second << ">";
}
auto i=v.cbegin(), end=v.cend();
if (i == end)
return string();
- ostringstream oss;
+ std::ostringstream oss;
oss << *i++;
while (i != end)
oss << delim << *i++;
}
template <class A>
-typename enable_if<is_const_iterable<A>::value && !is_same<A,string>::value, ostream>::type &
-operator<<(ostream & o, const A & a) {
+typename enable_if<is_const_iterable<A>::value && !is_same<A,string>::value, std::ostream>::type &
+operator<<(std::ostream & o, const A & a) {
return o << "[" << implode(a, ", ") << "]";
}
#include "verify.h"
#include "threaded_log.h"
-// struct tuple adapter, useful for marshalling
-// used like
+// struct tuple adapter, useful for marshalling and endian swapping. usage:
+//
// struct foo {
// int a, b;
// MEMBERS(a, b)
inline auto _tuple_() -> decltype(tie(__VA_ARGS__)) { return tie(__VA_ARGS__); } \
inline auto _tuple_() const -> decltype(tie(__VA_ARGS__)) { return tie(__VA_ARGS__); }
-// struct ordering and comparison
-// used like
-// struct foo {
-// int a, b;
-// MEMBERS(a, b)
-// };
+// struct ordering and comparison operations; requires the use of MEMBERS.
+// usage:
+//
// LEXICOGRAPHIC_COMPARISON(foo)
#define LEXICOGRAPHIC_OPERATOR(_c_, _op_) \
typedef typename make_indices_imp<S, tuple_indices<>, E>::type type;
};
+#define TUPLE_INDICES(_ArgPack_) typename make_tuple_indices<sizeof...(_ArgPack_)>::type()
+
// Template parameter pack expansion is not allowed in certain contexts, but
// brace initializers (for instance, calls to constructors of empty structs)
// are fair game.