summaryrefslogtreecommitdiff
path: root/src/common.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/common.hpp')
-rw-r--r--src/common.hpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/common.hpp b/src/common.hpp
index f46f93fd..0363c334 100644
--- a/src/common.hpp
+++ b/src/common.hpp
@@ -105,6 +105,10 @@ static inline Ordering ord(signed char l, signed char r)
{
return (l == r ? OrdEqual : (l > r ? OrdGreater : OrdLess));
}
+static inline Ordering ord(int l, int r)
+{
+ return (l == r ? OrdEqual : (l > r ? OrdGreater : OrdLess));
+}
static inline Ordering ord(short l, short r)
{
return (l == r ? OrdEqual : (l > r ? OrdGreater : OrdLess));
@@ -244,6 +248,11 @@ inline Join<T> join(const char *sep, const ::std::vector<T> v) {
namespace std {
template <typename T>
+inline auto operator<<(::std::ostream& os, const T& v) -> decltype(v.fmt(os)) {
+ return v.fmt(os);
+}
+
+template <typename T>
inline ::std::ostream& operator<<(::std::ostream& os, const ::std::vector<T*>& v) {
if( v.size() > 0 )
{
@@ -403,5 +412,17 @@ RunIterable<T> runs(const ::std::vector<T>& x) {
return RunIterable<T>(x);
}
+template<typename T>
+class NullOnDrop {
+ T*& ptr;
+public:
+ NullOnDrop(T*& ptr):
+ ptr(ptr)
+ {}
+ ~NullOnDrop() {
+ ptr = nullptr;
+ }
+};
+
#endif