X-Git-Url: http://xvm.mit.edu/gitweb/invirt/third/libt4.git/blobdiff_plain/f0dcb6b97d6d40f67698d1f71ac26970f1776f82..ebd5aef6dc92accb509b1cc67eaf72159f35cdfa:/types.h diff --git a/types.h b/types.h index 888cd68..0241bd3 100644 --- a/types.h +++ b/types.h @@ -75,6 +75,9 @@ using std::weak_ptr; using std::mutex; using lock = std::unique_lock; +#include +using std::runtime_error; + #include using std::ostringstream; using std::istringstream; @@ -138,6 +141,11 @@ template constexpr inline E to_enum(enum_type_t value) noexcept { // string manipulation +template +ostream & operator<<(ostream & o, const pair & d) { + return o << "<" << d.first << "," << d.second << ">"; +} + template inline typename enable_if::value, string>::type implode(const C & v, string delim=" ") { @@ -162,6 +170,12 @@ inline vector explode(const string & s, string delim=" ") { return out; } +template +typename enable_if::value && !is_same::value, ostream>::type & +operator<<(ostream & o, const A & a) { + return o << "[" << implode(a, ", ") << "]"; +} + #include "verify.h" #include "threaded_log.h"