C++ Logo

std-proposals

Advanced search

Re: [std-proposals] explicit modifier for R-value references

From: Bo Persson <bo_at_[hidden]>
Date: Mon, 19 Jun 2023 14:55:58 +0200
On 2023-06-19 at 14:11, Giuseppe D'Angelo via Std-Proposals wrote:
> Il 19/06/23 11:32, Frederick Virchanza Gotham via Std-Proposals ha scritto:
>> You could use it in function parameters as well:
>>
>> void SetVector( vector<int> &&explicit arg )
>> {
>> static vector<int> vec;
>> vec = arg; // no need for 'move' here
>> }
>
> This sounds extremely dangerous, because
>
> void SetVector( vector<int> && explicit arg )
> {
> use(arg); // e.g. print(arg). this is now use(std::move(arg))
> m_vec = arg; // hence this is using a moved-from instance
> }
>

Perhaps we could introduce a use(std::nomove(arg)); to use in this case?
   :-)

Received on 2023-06-19 12:56:04