首页 > 编程语言 > 详细

C++, std::move

时间:2020-01-21 10:22:39      阅读:75      评论:0      收藏:0      [点我收藏+]

0.

std::move is used to indicate that an object may be "removed from", allowing the efficient transfer of resources from t to another object. 

1. Examples:

#include <utility>

string str = "hello";
string str2 = std::move(str);    // transfer and str2 is "hello"
cout << str << endl;    // str is empty now

C++, std::move

原文:https://www.cnblogs.com/sarah-zhang/p/12219961.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!