summaryrefslogtreecommitdiffhomepage
path: root/compat
diff options
context:
space:
mode:
Diffstat (limited to 'compat')
-rw-r--r--compat/macros.hpp5
-rw-r--r--compat/math.hpp8
-rw-r--r--compat/run-in-thread.hpp2
-rw-r--r--compat/time.hpp1
4 files changed, 10 insertions, 6 deletions
diff --git a/compat/macros.hpp b/compat/macros.hpp
index 564dcc8d..abe89c73 100644
--- a/compat/macros.hpp
+++ b/compat/macros.hpp
@@ -64,5 +64,10 @@ constexpr force_inline void static_warn<true>() {}
#define static_warning(cond) \
static_warn<(cond)>(); \
+#define progn(...) (([&] { __VA_ARGS__ })())
+#define prog1(x, ...) (([&] { auto _ret1324 = (x); do { __VA_ARGS__; } while (0); return _ret1324; })())
+
// end c++-only macros
#endif
+
+#define once_only(...) do { static bool once__ = false; if (!once__) { once__ = true; __VA_ARGS__; } } while(false)
diff --git a/compat/math.hpp b/compat/math.hpp
index 5d80dace..014604e6 100644
--- a/compat/math.hpp
+++ b/compat/math.hpp
@@ -54,15 +54,15 @@ inline auto clamp(const t& val, const u& min, const w& max)
}
template<typename t>
-inline int iround(const t& val)
+inline auto iround(t val) -> std::enable_if_t<!std::is_integral_v<std::decay_t<t>>, t>
{
- return int(std::round(val));
+ return (int) std::round(val);
}
template<typename t>
-inline unsigned uround(const t& val)
+inline auto uround(const t& val) -> std::enable_if_t<!std::is_integral_v<std::decay_t<t>>, t>
{
- return std::round(std::fmax(t(0), val));
+ return (unsigned) std::fmax(0, std::round(val));
}
#include "macros.hpp"
diff --git a/compat/run-in-thread.hpp b/compat/run-in-thread.hpp
index b425532e..4631fb0c 100644
--- a/compat/run-in-thread.hpp
+++ b/compat/run-in-thread.hpp
@@ -93,7 +93,7 @@ run_in_thread_sync(QObject* obj, F&& fun)
QObject::connect(&src,
&QObject::destroyed,
obj,
- [&]() {
+ [&] {
traits::assign(ret, traits::call(fun));
sem.notify();
},
diff --git a/compat/time.hpp b/compat/time.hpp
index c246a9e5..bc422abe 100644
--- a/compat/time.hpp
+++ b/compat/time.hpp
@@ -14,7 +14,6 @@ static inline constexpr auto time_cast(u&& in)
}
using secs = duration<double>;
-using secs_ = duration<long>;
using ms = duration<double, std::milli>;
using us = duration<double, std::micro>;
using ns = duration<double, std::nano>;