See here, why break N is a bad idea.

The same applies to %%

 

https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3568r0.html
 

-----Ursprüngliche Nachricht-----
Von: Frederick Virchanza Gotham via Std-Proposals <std-proposals@lists.isocpp.org>
Gesendet: Sa 23.05.2026 10:23
Betreff: Re: [std-proposals] return value lives until end of scope
An: std-proposals@lists.isocpp.org;
CC: Frederick Virchanza Gotham <cauldwell.thomas@gmail.com>;


On Saturday, May 23, 2026, Sebastian Wittmeier wrote:

 

You can use a single variable (container for futures) and use it as reference parameter to a function creating your async call.

 
 
I think the following:
 
int main()
{
 
for ( unsigned i = 0u; i < N; ++i )
{
    %%async(Func);
}
 
}
 
would have to be implemented by the compiler something like:
 
int main()
{
 
struct Frame {
    alignas(std::future<int>) char unsigned f[ sizeof(std::future<int>) ];
    Frame *next;
};
 
Frame fr;
Frame *p = &fr;
 
for ( unsigned i = 0u; i < N; ++i )
{
    ::new(p->f) std::future<int>{ async(Func) };
    p->next = alloca( sizeof *p );
    p->next.next = nullptr;
    p = p->next;
}
 
for ( p = &fr; nullptr != p; p = p->next )
{
    ((std::future<int>*)p->f)->~std::future<int>();    
}
 
 
-- 
 Std-Proposals mailing list
 Std-Proposals@lists.isocpp.org
 https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals