Im interested in the following (psudocode):
void set_it_up {
A a{};
//OK to use a...
execute_it_later([&]{return a;});//When gets executed later, a has been destroyed...
//here a also OK
}
Now Im well aware that this is usually fine to do something like this - if the lambda is used before the object gets destroyed.
But, is it possible to avoid capturing a
somehow (making the code malformed) ? (lets just say I want to avoid 'accidents' to happend in the future by mistakenly capturing a temporary that gets de-allocated early).
Can I somehow openly show that A is a temporary that it shouldn't get a reference binding to ?
I can modify A as much as I want.