AUI_DO_ONCE#
Executes following function call or {} block once per program execution
| Header: | #include <AUI/Util/kAUI.h> |
| CMake: | aui_link(my_target PUBLIC aui::core) |
Definition#
Detailed Description#
Guarantees that the following code block will be executed only once per application execution.
| without | with |
Examples#
examples/ui/views/src/ExampleWindow.cpp
Views Example — All-in-one views building example.
_new<AButton>("Add").connect(
&AButton::clicked, this,
[state] {
static std::default_random_engine re;
AUI_DO_ONCE { re.seed(std::time(nullptr)); };
static std::uniform_real_distribution<float> d(0.f, 1.f);
state->colors.writeScope()->push_back({ AColor(d(re), d(re), d(re), 1.f) });
}),
_new<AButton>("Remove").connect(
&AButton::clicked, this,