diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2018-07-18 07:02:15 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2018-07-24 00:41:32 +0200 |
commit | 3ddb332e6314887378ddbd49c9ebc49fb4ae2d54 (patch) | |
tree | 1fd49f1785e30bd883e2b033a585584b554dbe8c /compat/macros.hpp | |
parent | ea8c848d4b06db8a4701fa4eaefb94b0035b25aa (diff) |
compat/macros: more decltype(auto)
Diffstat (limited to 'compat/macros.hpp')
-rw-r--r-- | compat/macros.hpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/compat/macros.hpp b/compat/macros.hpp index f7fa8f73..465a7d24 100644 --- a/compat/macros.hpp +++ b/compat/macros.hpp @@ -75,7 +75,7 @@ using to_const_lvalue_reference_t = remove_cvref_t<t> const&; #define eval_once__2(expr, ident) eval_once__3(expr, ident) #define eval_once__3(expr, ident) \ - ([&] { \ + ([&]() -> decltype(auto) { \ static auto INIT##ident = (expr); \ return static_cast<to_const_lvalue_reference_t<decltype(INIT##ident)>>(INIT##ident); \ }()) @@ -96,9 +96,13 @@ constexpr cc_forceinline void static_warn<true>() {} #define static_warning(cond) \ static_warn<(cond)>(); \ -#define typed_progn(type, ...) (([&] () -> type { __VA_ARGS__ })()) -#define progn(...) (([&] { __VA_ARGS__ })()) -#define prog1(x, ...) (([&] { decltype(auto) ret1324 = (x); __VA_ARGS__; return ret1324; })()) +#define typed_progn(type, ...) (([&]() -> type { __VA_ARGS__ })()) +#define progn(...) (([&]() -> decltype(auto) { __VA_ARGS__ })()) + +#define prog1(x, ...) (([&]() -> to_const_lvalue_reference_t<decltype((x))> \ + { \ + decltype(auto) ret1324 = (x); __VA_ARGS__; return ret1324; \ + })()) // end c++-only macros #endif |