On Thu, 29 Jun 2023, 06:51 Federico Kircheis via Std-Proposals, <std-proposals@lists.isocpp.org> wrote:

PS: I think there is a similar classes in a paper, I'm not able to find
it right now.

As already discussed, it's synchronized_value in the Concurrency TS V2. It's sorted by gcc already.

This entire thread is giving me deja vu. The idea of locking on every access has already been discussed and rejected as the wrong granularity (and the committee will not approve such misguided proposals). The idea of a locked value with an accessor taking a callable to operate on the value is already in a C++ TS.