From f50ac3549d6a7f1199fa012e4b03f581bc8d305b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 22 Jun 2018 12:54:47 +0200 Subject: core, modules: modernize syntax only Use more C++17 features where this helps any. --- compat/macros.hpp | 5 +++++ compat/math.hpp | 8 ++++---- compat/run-in-thread.hpp | 2 +- compat/time.hpp | 1 - 4 files changed, 10 insertions(+), 6 deletions(-) (limited to 'compat') 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() {} #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 -inline int iround(const t& val) +inline auto iround(t val) -> std::enable_if_t>, t> { - return int(std::round(val)); + return (int) std::round(val); } template -inline unsigned uround(const t& val) +inline auto uround(const t& val) -> std::enable_if_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; -using secs_ = duration; using ms = duration; using us = duration; using ns = duration; -- cgit v1.2.3