C++ Logo

std-proposals

Advanced search

Re: [std-proposals] std::elide

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Wed, 22 May 2024 15:37:07 +0100
On Wed, May 22, 2024 at 2:17 PM Tiago Freire wrote:
>
> While I can understand RVO, mutexes has got to be
> the worst possible example for an application of this.


Let's say it's Summer time and I'm out the back garden at my house on
a sunny day, and I'm trying out my brand new fruit blender. Tiago, you
come over to my house and I've already made my smoothie, but there's
still one pineapple sitting on the table, and even though a pineapple
isn't a great choice of fruit for blending, it's right there right now
and so I just grab it and throw it in the blender to show off my new
blending skills. I could have stood up and walked into my house to the
kitchen to grab a softer piece of fruit but I'm just not bothered --
the pineapple is there and it will do.

We've been consistently using "std::mutex" because it's right there
right now. We just need to write "#include<mutex>" and we have an
unmovable-and-uncopyable type. That's literally the only reason we're
all talking about mutexes in this thread. It's easier to write those
15 characters, "#include<mutex>", than to go to the bother of typing
out:

    struct S {
        MyClass(MyClass const &) = delete;
        MyClass(MyClass &&) = delete;
        int n;
    };

You seem to be very technically-minded Tiago and perhaps that's why
you drill further into the logic than the rest of us here. Sometimes
though, we just want a quick-and-easy example to demonstrate an idea
we're working on -- and sometimes we don't give much consideration to
how sensible our quick-and-easy example is. The world would probably
be a better place if we were all as analytically-prone as you Tiago,
but for the time being we just want to write out short little simple
code snippets.

Received on 2024-05-22 14:37:21