课程: C++ Development: Advanced Concepts, Lambda Expressions, and Best Practices
今天就学习课程吧!
今天就开通帐号,24,100 门业界名师课程任您挑!
Using std::move - C++教程
课程: C++ Development: Advanced Concepts, Lambda Expressions, and Best Practices
Using std::move
- [Instructor] The C++ Standard Library provides a template function called move, which tells the compiler to treat an object as a movable R value. While standard move looks like a function call, it actually works more like a typecast. This is vectortest.cpp from chapter two of the exercise files. Let's take a look at how a move operation works in practice. The standard move utility function is in the utility header. We have this convenient function disp_v. This is simply for displaying the contents of a vector, and we'll talk about this swap function in a minute. First, let's get down here to main. And we see we have two vectors of string. That's the STL string class, and they have the content one, two, three, four, five, and six, seven, eight, nine, 10. I'm want to go ahead and build and run this. We're displaying them with the disp_v function. And when I run it, you see we have v1 is one, two, three, four, five, and v2…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。