C++ Logo

std-proposals

Advanced search

Re: [std-proposals] std::elide

From: Thiago Macieira <thiago_at_[hidden]>
Date: Wed, 22 May 2024 20:57:09 -0300
On Wednesday 22 May 2024 18:23:58 GMT-3 Frederick Virchanza Gotham via Std-
Proposals wrote:
> Nobody on here wants to return a locked mutex by value from a
> function. Not one person. 0% of the people on this mailing list wish
> to return a locked mutex by value from a function. The count of
> persons who plan to write a function to return by value a mutex which
> has already been locked is zero. Nobody. No one.

They why are you insisting on it, despite being asked multiple times to find
other uses?

Tiago's argument was that the reasons why you don't want to do that for
std::mutex may apply to for any other class type, so he's asking you to give a
couple of real examples where the feature would be useful and what
alternatives exist. You haven't done that.

> No matter how many times it's re-iterated on this mailing list that
> the whole locked mutex thing is just a quick-and-easy example, more

And that's the issue. Stop giving quick-and-dirty examples because they lead
people to the wrong path. Give a *proper* example.

Not a gimmick class either. A real one. Preferably, three different ones, so we
know this is a real problem, not just an accident of bad API design somewhere.

> If you want good examples of returning post-constructionally-modified
> objects by value from a function, there's load of examples given in
> Anton's paper:
>
> https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2025r2

Thank you.

That's not a good example. It's doing the same thing you did: it posits a
arbitrary immovable type and proceeds to discuss what to do with it. Tiago's
point stands: we need to understand first *why* said type is immovable so we
can discuss whether doing what you're asking even makes sense.

The only widget I know and care about is QWidget and, like a mutex, it's
tracked by address (which is why they aren't movable). I don't know about
other libraries, you'll have to give us the example and argue why this type of
construction should be allowed.

> So if we talk about widgets instead of mutexes then can all this
> codswallop come to an end?

No. Because widgets have the same problem: they are tracked by address.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Principal Engineer - Intel DCAI Fleet Engineering and Quality

Received on 2024-05-22 23:57:20