diff options
Diffstat (limited to 'compat/util.hpp')
-rw-r--r-- | compat/util.hpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/compat/util.hpp b/compat/util.hpp index 7a6858a3..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>; @@ -22,7 +27,7 @@ int iround(const t& val) return int(std::round(val)); } -namespace detail { +namespace util_detail { template<typename n> inline auto clamp_(n val, n min, n max) -> n @@ -39,5 +44,13 @@ inline auto clamp_(n val, n min, n max) -> n template<typename t, typename u, typename w> inline auto clamp(const t& val, const u& min, const w& max) -> decltype(val * min * max) { - return ::detail::clamp_<decltype(val * min * max)>(val, min, max); + 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>; |