"C + + Design new thinking" command design pattern

Source: Internet
Author: User

Original content withdrawal:

The 5th chapter of the book is the generalization of imitation functions, I think this chapter really tells the content can be summed up a sentence!

How to use the old C + + standard to implement the c++11 new standard similar to Std::function provides functionality.

std::function Introduction:

Analysis Std::function Source, std::function a lot of use of the new standard features, variable length parameters template, perfect forwarding and so on.

callable Body in C + +:

The callable body in C + + can now be added

1.c-like function

2.c-like Pointer to function

3.reference to function

4.function Object

5.pointer to member function


7.c++11 Lambda

functor in the article:

For any of the above listed items, you can add a pair of parentheses () to the right and put a set of appropriate parameters inside to perform a processing action.

After that, the functor described is the encapsulation in 1-6 callable form. Functor can be passed, for different calling bodies, but with the same invocation form, providing a uniform type.

The real review:

The author laments on page 105 that "a variable number of template parameters" does not exist at all. (c++11 variable length parameter template)

Although paddle, the real craftsmen and the constraints of the production tools will not compromise, the author of this book is so.

In the book 122 pages, discusses the cost of the forwarding function, mentions "reference folding" in the endnote, the parent of C + + Bjarne Stroustrup submits the report, allowing the use of reference to reference.

(c++11 reference folding, perfect forwarding Std::forward)

What is proficiency in a language?

1. Recognize the limitations of language and how to use programming techniques to eliminate this limitation.

2. Be able to predict, assert, and even influence the future development of the language.

It is the one who takes it, and our goal is to be proficient in a language.

"C + + Design new thinking" command design pattern

Related Article

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.