How I understand C + + move semantics (rvalue reference) and perfect forwarding (perfect forwarding)

Source: Internet
Author: User

In fact, the main is three articles (blog):

This article is the most.

Http://thbecker.net/articles/rvalue_references/section_01.html

From here you can know when you'll know when you can "chain" call the move constructor and when you can't, understand some of the nuances of the process (especially when it doesn't), you'll almost know what a move semantic is.

Then Scott Meyers's Universal Reference in c++11:

Https://isocpp.org/blog/2012/11/universal-references-in-c11-scott-meyers

As a supplementary explanation of the first article. If you still have doubts, or doubt, then this article will help you to confirm your thoughts.

Then there was a C + + proposal for move semantic in 2002:

Http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2002/n1377.htm

From here you can know that the original move semantics only for those large objects have meaning, for the built-in type (such as int), move and copy no difference ("down to the Machine instructions"). (Knowing this is really important to me, because knowing at the bottom, for built-in types, like Int,move and copy, is no different, more or less the mystery of Std::move ()

The first and third articles are all about perfect forwarding. Derivatives.

You can also take a look at Scott Meyers's 2013 speech about universal reference, which is very good (Scott Meyers This is a natural joke hand):

Https://channel9.msdn.com/events/GoingNative/2013/An-Effective-Cpp11-14-Sampler (this should be it ...) Internet is too slow to open to see)

Finally, of course you can look at what's on StackOverflow:

Http://stackoverflow.com/questions/3106110/what-are-move-semantics

(From here you can not only learn about move Sematics, but also know what copy and Swap technique (rule of three).

How I understand C + + move semantics (rvalue reference) and perfect forwarding (perfect forwarding)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.