summaryrefslogtreecommitdiffhomepage
path: root/compat/macros.hpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2018-07-02 08:20:47 +0200
committerStanislaw Halik <sthalik@misaki.pl>2018-07-02 09:34:17 +0200
commitf2faf7acf4445fef2a149ebbdecb569a2d119d94 (patch)
tree6629ba211a70a54a0ab82f6c4f4de08504072951 /compat/macros.hpp
parent66e75860d0c54baa39ed789442b09b96eeebe2e6 (diff)
nothing important
Diffstat (limited to 'compat/macros.hpp')
-rw-r--r--compat/macros.hpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/compat/macros.hpp b/compat/macros.hpp
index 61c49975..0807df4c 100644
--- a/compat/macros.hpp
+++ b/compat/macros.hpp
@@ -44,8 +44,13 @@
// from now only C++
+#include <utility>
+
//#define once_only(...) do { static bool once__ = false; if (!once__) { once__ = true; __VA_ARGS__; } } while(false)
-#define once_only(expr) ([&] { static decltype(auto) ret___1132 = (expr); return ret___1132; }())
+//#define once_only(expr) ([&] { static decltype(auto) ret___1132 = (expr); return (decltype(ret___1132) const&) ret___1132; }())
+
+#define eval_once__2(expr, ident) (([&] { static bool ident = ((expr), true); (void)(ident); }))
+#define eval_once(expr) eval_once__2(expr, PP_CAT(eval_once_init__, __COUNTER__))
#include <type_traits>