Some modern programming languages like Odin or Go implement a feature called deferred code execution. C++ is not one of them. Luckily, Unreal Engine has it's own solution to this.
at the end of the ON_SCOPE_EXIT scope you need to add a semicolon.
ON_SCOPE_EXIT
{
std::cout << "deferred text" << std::endl;
};
at the end of the ON_SCOPE_EXIT scope you need to add a semicolon.
ON_SCOPE_EXIT
{
std::cout << "deferred text" << std::endl;
};