C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Copy-construct, move-construct, and PR-construct

From: Thiago Macieira <thiago_at_[hidden]>
Date: Wed, 23 Aug 2023 18:31:13 -0700
On Wednesday, 23 August 2023 09:01:25 PDT Breno Guimarães via Std-Proposals
wrote:
> Perhaps a fair addition to the language is to allow RVO with slicing iff
> sizeof(Base) == sizeof(Derived):
>
> struct LockedMutex : public std::mutex {
> LockedMutex() { lock(); }
> };

How about instead we add a constructor to std::mutex to allow it to be born
locked? I'd also like to request a far more useful feature of requesting an
adaptive-spinning mutex.

The above would be a more generic solution, but how often do we need it? What
are the risks involved with having it? I've done what you've suggested many
times (last night even), but it's always a hack. Given the risks and given we
have alternatives that don't incur that risk, is it worth it?

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel DCAI Cloud Engineering

Received on 2023-08-24 01:31:15