From a1f5e2953442655609c6bca03c32a962dd3f1711 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 12 May 2017 15:41:57 +0200 Subject: compat/util: add PROG1, adjust clamp --- compat/util.hpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'compat/util.hpp') diff --git a/compat/util.hpp b/compat/util.hpp index 735fbae6..823b83d1 100644 --- a/compat/util.hpp +++ b/compat/util.hpp @@ -13,10 +13,14 @@ #include #define progn(...) ([&]() { __VA_ARGS__ }()) +#define prog1(x, ...) (([&]() { auto _ret1324 = (x); do { __VA_ARGS__; } while (0); return _ret1324; })()) #define once_only(...) progn(static bool once = false; if (!once) { once = true; __VA_ARGS__; }) - -#define load_time_value(x) progn(static const auto _value132((x)); return _value132;) +#define load_time_value(x) \ + progn( \ + static const auto _value132((x)); \ + return static_cast(value132); \ + ) template using mem = std::shared_ptr; template using ptr = std::unique_ptr; @@ -76,9 +80,9 @@ inline auto clamp_(n val, n min, n max) -> n } template -inline auto clamp(const t& val, const u& min, const w& max) -> decltype(val * min * max) +inline auto clamp(const t& val, const u& min, const w& max) -> decltype(val + min + max) { - return ::util_detail::clamp_(val, min, max); + return ::util_detail::clamp_(val, min, max); } template -- cgit v1.2.3