C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Function-bound objects with unary operator %

From: Zhihao Yuan <zy_at_[hidden]>
Date: Mon, 01 Jun 2026 20:39:41 +0000
On Monday, June 1st, 2026 at 12:25 PM, Sebastian Wittmeier via Std-Proposals <std-proposals_at_[hidden]> wrote:

> That is quite dangerous for dead locks and not locked accesses. If you need it, then use std::optional

What does "that" refer to?

--
Zhihao Yuan, ID lichray
The best way to predict the future is to invent it.
_______________________________________________
> 
> 
> > -----Ursprüngliche Nachricht-----
> > Von: Zhihao Yuan via Std-Proposals <std-proposals_at_[hidden]>
> > Gesendet: Mo 01.06.2026 20:40
> > Betreff: Re: [std-proposals] Function-bound objects with unary operator %
> > Anlage: signature.asc
> > An: std-proposals_at_[hidden];
> > CC: Zhihao Yuan <zy_at_[hidden]>;
> > On Monday, June 1st, 2026 at 7:43 AM, Frederick Virchanza Gotham via Std-Proposals <std-proposals_at_[hidden]> wrote:
> > 
> > > So what is this feature good for? Well you can spontaneously lock a
> > > mutex at any point in a function:
> > >
> > 
> > >    void Func(void)
> > >    {
> > >       if ( a )
> > >       {
> > >          if ( b )
> > >          {
> > >              if ( c )
> > >              {
> > >                 %lock_guard{ my_global_mutex };
> > >              }
> > >          }
> > >       }
> > >
> > 
> > >       DoSomething();
> > >    }
> > >
> > 
> > 
> > Python standard library offers an
> > ExitStack to address the demand.
> > The benefit of ExitStack is that,
> > since it creates yet another
> > variable, you can designate which
> > scope your `%` binds to. Maybe
> > you can repurpose goto labels for
> > this, but a library solution still
> > looks more powerful.
> > 
> > --
> > Zhihao Yuan, ID lichray
> > The best way to predict the future is to invent it.
> > _______________________________________________
> > --
> > Std-Proposals mailing list
> > Std-Proposals_at_[hidden]
> > https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

Received on 2026-06-01 20:39:53