C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Return Value Optimisation whenever you need it (guaranteed elision)

From: Jason McKesson <jmckesson_at_[hidden]>
Date: Sat, 12 Aug 2023 09:47:40 -0400
On Sat, Aug 12, 2023 at 6:58 AM Frederick Virchanza Gotham via
Std-Proposals <std-proposals_at_[hidden]> wrote:
>
> I reply in series to Thiago and Jason below.
>
>
> On Sat, Aug 12, 2023 at 3:13 AM Jason McKesson wrote:
> >
> > p = new(p) mutex(Func(5, 6.3, 8.4f));
>
>
> That's really cool, I didn't know we could do that. I tried it just
> now on Godbolt with an atomic<int>:
>
> https://godbolt.org/z/znPo9MeET
>
>
> > There's no equivalent for `optional`, but that's nonsensical.
>
>
> A window could optionally contain a timer, something like:
> class Window { optional<Timer> timer; };
> And then there could be a threadsafe function that allocates timers
> from a pool of 8, and blocks until one becomes available.
>
> Not only should we be able to put a unmovable-and-uncopiable return
> value inside an 'optional', but we should be able to put it inside a
> 'variant or an 'any' also.

That's not a thing that should be done without the direct and explicit
involvement *of those types*. This counts doubly so for `any`, because
its initialization needs to change based on the properties of the `T`
it is given.

A type's non-trivial initialization is not something you get to bypass
just because you think it'd be nice to do so.

> On Sat, Aug 12, 2023 at 12:13 AM Thiago Macieira wrote:
> >
> > Attributes are not allowed to modify the syntactic correctness of the program.
> > So if the code doesn't compile today without that attribute, the presence of
> > the attribute can't make it compile.
>
>
> I bet ChatGPT can figure this one out. Here's what I typed in:

... what? OK, one of two things seems to be going on here.

On the one hand, this could be an act of mockery. You believe your
proposal for using attributes was perfectly fine as-is. You believe
that people pointing out that your suggestion isn't appropriate for
C++ are just being needlessly obstinate or whatever by focusing on
syntax. As such, you're mocking them by basically telling them to
consult a chat-bot as an act of parody.

Alternatively... you are being sincere. So when you throw the
ramblings of a chat-bot at us, this is being done with the sincere
belief that its outputs are meaningful and represent legitimate,
reasonable solutions to the problem at hand. But you also didn't
manually look through those problems; you just dumped the spew itself
into the mailing list. Which suggests that you think the form and
structure of C++ syntax is so unimportant that it is perfectly
reasonable to relegate sorting out the details on that matter to a
chat-bot without you doing any kind of even cursory overview of its
results.

I don't know which of these is true, but either one is not a good
look. Please don't do that again.

Received on 2023-08-12 13:47:53