summaryrefslogtreecommitdiffhomepage
path: root/compat
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2018-12-24 18:58:21 +0100
committerStanislaw Halik <sthalik@misaki.pl>2018-12-24 19:32:10 +0100
commitdb03e6816bc41572ba4c3639d26e0485c8ab03b3 (patch)
tree68d5f6d260f35beaef8f5fe8a66ad06f23d70385 /compat
parentd6e7fd75bf6005c8f029ee3821d55fea13affc35 (diff)
compat/macros: fix eval_once
Using with `qDebug()' didn't work. Remove return type.
Diffstat (limited to 'compat')
-rw-r--r--compat/macros.hpp13
1 files changed, 5 insertions, 8 deletions
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<std::add_const_t<remove_cvr
// the ICE is caused by decltype(auto) and const& return value
//#define eval_once(expr) ([&]() -> 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<to_const_cvref_t<decltype(INIT##ident)>>(INIT##ident); \
+#define eval_once2(expr, ctr) \
+ ([&] { \
+ [[maybe_unused]] \
+ static auto PP_CAT(eval_once_, ctr) = (((void)(expr)), 0); \
}())
-#include <type_traits>
-
template<typename t>
using cv_qualified = std::conditional_t<std::is_fundamental_v<remove_cvref_t<t>>,
remove_cvref_t<t>,