Last active
February 27, 2022 21:17
-
-
Save Unknown6656/d5bfd62223b7f5007e07397c5284bf17 to your computer and use it in GitHub Desktop.
An initializer block for constant fields, variables, and members
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace unknown6656___init_block | |
{ | |
struct __empty {}; | |
template <class F> | |
inline decltype(auto) operator+(__empty, F&& f) noexcept | |
{ | |
return std::forward<F>(f)(); | |
} | |
} | |
#define init unknown6656___init_block::__empty{} + [&]() -> decltype(auto) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This gist allows developers to use an initializer block for constant variables and members
Usage example:
The code above prints: