summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-12-03 07:11:16 +0100
committerStanislaw Halik <sthalik@misaki.pl>2016-12-03 07:11:16 +0100
commit2c80de4bf9ba4a7ee852540168c3de9bc9ec17d9 (patch)
treef643c34200ad2c4034b2b446a7aa12cee56e4cdc
parent7af59eda13eb8dcbb14e6db71266772f5ea663e9 (diff)
fixup! tracker/{aruco,pt}: use RAII for QObject
-rw-r--r--compat/util.hpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/compat/util.hpp b/compat/util.hpp
index a63e245f..5b9e2c69 100644
--- a/compat/util.hpp
+++ b/compat/util.hpp
@@ -1,10 +1,15 @@
#pragma once
+#include "ndebug-guard.hpp"
+
#include "make-unique.hpp"
#include "run-in-thread.hpp"
#include <memory>
#include <cmath>
+#include <utility>
+
+#include <QSharedPointer>
#define progn(...) ([&]() { __VA_ARGS__ }())
template<typename t> using mem = std::shared_ptr<t>;
@@ -41,3 +46,11 @@ inline auto clamp(const t& val, const u& min, const w& max) -> decltype(val * mi
{
return ::util_detail::clamp_<decltype(val * min * max)>(val, min, max);
}
+
+template<typename t, typename... xs>
+auto qptr(xs... args)
+{
+ return QSharedPointer<t>(new t(std::forward<xs>(args)...));
+}
+
+template<typename t> using qshared = QSharedPointer<t>;