织梦CMS - 轻松建站从此开始!

欧博ABG官网-欧博官方网址-会员登入

unique require std::move() to an empty unique

时间:2026-02-11 21:15来源: 作者:admin 点击: 0 次
It's not, because in both cases the expression may bind to an rvalue reference. In the first, std::make_unique already returns a pure rvalue. In the

It's not, because in both cases the expression may bind to an rvalue reference.

In the first, std::make_unique already returns a pure rvalue.

In the second, std::move does a cast to an rvalue reference, it's redundant.

It also doesn't matter if the destination object is empty or not. The mere act of invoking assignment doesn't depend on how the reference it received was bound. The result would be the same, the previous (possibly non-existent) resource in the target will be replaced by the one "stolen" from the source.

(责任编辑:)
------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 验证码:
发布者资料
查看详细资料 发送留言 加为好友 用户等级: 注册时间:2026-02-12 01:02 最后登录:2026-02-12 01:02
栏目列表
推荐内容