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
6.ctor
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