C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Relocating destructor and operator reloc

From: 李 秋逸 <QiuyiLi1023_at_[hidden]>
Date: Fri, 28 Jun 2024 16:53:23 +0000
I'm agree about what you said and have thought about it before. The first solution in my mind is introducing a new attribute (such as [[is_return_value]]) to tell the complier which is the return value and force to NRVO. But I'm not sure whether it is a good idea.

________________________________
发件人: Std-Proposals <std-proposals-bounces_at_[hidden]> 代表 F. v.S. via Std-Proposals <std-proposals_at_[hidden]>
发送时间: 星期六, 六月 29, 2024 12:43:51 上午
收件人: std-proposals_at_[hidden]rg <std-proposals_at_[hidden]>
抄送: F. v.S. <de34_at_[hidden]>
主题: [std-proposals] 回复: Relocating destructor and operator reloc

I totally disagree on that this can be an easy and flexible way. But I'd hear what other guys say.

It seems to me that when the new relocating "destructor" is not defaulted, the identity (or the address) of the returned object (i.e. the destination of relocation) ALMOST ALWAYS needs to be known in the function body. So it'll be simpler, at least to me, to invent a new way to directly refer to the destination object, instead of finding how to guarantee NRVO.

Thanks,
F.v.S.
________________________________
From: Std-Proposals <std-proposals-bounces_at_[hidden]> on behalf of 李 秋逸 via Std-Proposals <std-proposals_at_[hidden]>
Sent: Saturday, June 29, 2024 0:31
To: std-proposals_at_[hidden]cpp.org <std-proposals_at_[hidden]>
Cc: 李 秋逸 <QiuyiLi1023_at_[hidden]>
Subject: [std-proposals] Relocating destructor and operator reloc

Sorry for bother you. Seeing some proposals about relocating in C++, I think I found a easy and flexible way to do this with least changes to the core feature of C++ language. You can check it in the attachment or click https://github.com/YandereChan2/Relocating-destructor-and-operator-reloc/blob/main/Operator%20reloc%20and%20relocating%20destructor.md .

The core idea is introduce a new destructor T ~T(int), and with the help of RVO/NRVO to relocate an object from one address to the address of the return value.

Received on 2024-06-28 16:53:28