Article 41: Understanding implicit interfaces and compile-time polymorphism
n Classes and templates both support interface and polymorphic
N for classes, the interface is explicit, with the function signature as the center, and polymorphism through the virtual function in the run time.
N for the templates parameter, the interface is implicit, based on the valid expression, polymorphism is through template with the initialization and function overload resolution occurs in the compiler.
Article 42: Understanding the dual meaning of TypeName
N Declare template parameters, prefix keyword class and typename are interchangeable.
n Use the Keyword typename to identify a nested subordinate type name, but not as a base class modifier within a base class or member initial column.
Article 43: Learning to handle names within a templated base class
Templates can also be inherited as base classes, and member functions of derived classes can use three methods if you want to access the function version of the base class: The first is to add This-> before the base class function call, and the second is to use the using declaration, and the third is to understand that the function being called is inside the base class.
Article 44: Extracting parameter-independent code from a template
Article 45: Use the member function template to accept all compatible types
Clause 46: Define a non-member function for a template when a type conversion is required
n When we write a class template, and the function it provides that is related to this template supports implicit type conversions for all parameters, define those functions as friend functions inside the class template.
Article 47: Using traits class performance type information
The N traits class makes the type-related information available to the compiler, which is implemented with templates and template specificity
n after consolidating the overloaded technology, it is possible for the traits class to perform if...else on the type at compile time ... Test
Article 48: Template meta-programming
N Template metaprogramming enables early error detection and higher execution efficiency by moving the operation to the compile time.
Article 49: Understanding New-handler Behavior
N Set_new_handler allows a client to specify a function that is called when the memory allocation is not met.
Article 50: Understanding the appropriate replacement time for new and delete
The three most common reasons to replace operator new AND operator delete are:
Used to detect errors in use;
In order to enhance efficiency;
In order to collect statistical data on use;
Article 51: You need to stick to the routine when writing new and delete
n operator new should contain an infinite loop in which to attempt to allocate memory, and if it fails to meet memory requirements, the call is New-handler, and it should also be able to handle a 0-byte request. The class-specific version should also handle applications that are larger than the correct size.
n operator delete should not do anything when a null pointer is received. The class-specific version should also handle error requests that are larger than the correct size.
Clause 52: Write placement new also to write placement delete
When you write a placement new, make sure to also write out the corresponding placement operator delete if you do not do so, the program may occur with a hidden micro-time memory leak.
When you declare placement new and placement Delete, make sure that you do not inadvertently obscure their normal version.
Article 53: Don't overlook compiler warnings
n Take the compiler's warning message seriously and try to win the honor without any warning at the highest warning level of your compiler.
n do not rely too much on compiler alarm capabilities, because different compilers treat things differently, and once ported to another compiler, the warning messages you rely on may disappear.
Article 54: Familiarize yourself with the standard library of programs including TR1
The main functions of the n C + + standard library consist of STL, iostream, locales and include C99 standard library.
n TR1 added support for smart pointers, generalized function pointers, hash_based containers, regular expressions, and 10 additional components.
n TR1 itself is only a specification, in order to obtain the benefits offered by TR1, need a physical, a good source of physical is boost
Article 55: Get familiar with boost
Boost is a community and a Web site dedicated to the development of C + + libraries that are free, open source, and peer reviewed. Boost plays a powerful role in the C + + standardization process.
Boost offers many TR1 component implementations, as well as many other library applications.
"Effective C + +" Reading notes 4