From db03e6816bc41572ba4c3639d26e0485c8ab03b3 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 24 Dec 2018 18:58:21 +0100 Subject: compat/macros: fix eval_once Using with `qDebug()' didn't work. Remove return type. --- compat/macros.hpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'compat/macros.hpp') diff --git a/compat/macros.hpp b/compat/macros.hpp index deb9c9bf..89e095dd 100644 --- a/compat/macros.hpp +++ b/compat/macros.hpp @@ -27,17 +27,14 @@ using to_const_cvref_t = std::add_lvalue_reference_t decltype(auto) { static decltype(auto) ret___1132 = (expr); return (decltype(ret___1132) const&) ret___1132; }()) -#define eval_once(expr) eval_once__2(expr, PP_CAT(_EVAL_ONCE__, __COUNTER__)) -#define eval_once__2(expr, ident) eval_once__3(expr, ident) +#define eval_once(expr) eval_once2(expr, __COUNTER__) -#define eval_once__3(expr, ident) \ - ([&]() -> decltype(auto) { \ - static auto INIT##ident = (expr); \ - return static_cast>(INIT##ident); \ +#define eval_once2(expr, ctr) \ + ([&] { \ + [[maybe_unused]] \ + static auto PP_CAT(eval_once_, ctr) = (((void)(expr)), 0); \ }()) -#include - template using cv_qualified = std::conditional_t>, remove_cvref_t, -- cgit v1.2.3