Date: Tue, 11 Apr 2023 23:02:13 +0100
On Tue, Apr 11, 2023 at 5:47 PM Sebastian Wittmeier via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> So here is my suggestion: make it possible to exit lambdas with goto,
> with the same/similar semantics to throwing and catching an exception.
>
> Can that be implemented with lower overhead than actually using an
> exception?
I also tried messing around with the following:
int Func(void)
{
std::jmp_buf jb;
if ( 0 != setjmp(jb) )
{
// also do other stuff in here
return 42;
}
auto monkey = [&jb](void)->void { std::longjmp(jb,1); };
monkey();
}
but I think the other solutions make more sense. Or just throw and
catch an exception.
<std-proposals_at_[hidden]> wrote:
>
> So here is my suggestion: make it possible to exit lambdas with goto,
> with the same/similar semantics to throwing and catching an exception.
>
> Can that be implemented with lower overhead than actually using an
> exception?
I also tried messing around with the following:
int Func(void)
{
std::jmp_buf jb;
if ( 0 != setjmp(jb) )
{
// also do other stuff in here
return 42;
}
auto monkey = [&jb](void)->void { std::longjmp(jb,1); };
monkey();
}
but I think the other solutions make more sense. Or just throw and
catch an exception.
Received on 2023-04-11 22:02:25