
Effective C++
GetRekt
这个作者很懒,什么都没留下…
展开
-
Effective C++: Item 40 -- Use multiple inheritance judiciously
注: 此为英文资料整理,如需翻译请私信或留评论Multiple Inheritance (MI) DefinitionMultiple inheritance just means inheriting from more than one base class, but it is not uncommon for MI to be found in hierarchies that hav...原创 2019-08-26 11:49:10 · 217 阅读 · 0 评论 -
Effective C++: Item 47 -- Use traits classes for information about types(check type in compile time)
Mini-review on STL Iterator Category5 categories of iterators:Input iterators can move only forward, can move only one step at a time, can only read what they point to, and can read what they’re po...原创 2019-09-04 11:10:38 · 255 阅读 · 0 评论 -
Effective C++: Item 46:Define non-member functions inside templates when type conversions are desire
ExampleModification on example from Item 24.template<typename T>class Rational { public: Rational(const T& numerator = 0, // see Item 20 for why params const T& denominator =...原创 2019-09-03 11:59:17 · 172 阅读 · 0 评论 -
Effective C++: Item 45 -- Use member function templates to accept “all compatible types.”
SmartPtr exampleSmart pointers are objects that act much like pointers but add functionality pointers don’t provide. However, one of the things that real pointers do well is support implicit conversi...原创 2019-09-02 10:55:49 · 196 阅读 · 0 评论 -
Effective C++: Item 44 -- Factor parameter-independent code out of templates
Problem:Using templates can lead to code bloat: binaries with replicated (or almost replicated) code, data, or both.The result can be source code that looks fit and trim, yet object code that’s fat ...原创 2019-08-30 11:26:08 · 251 阅读 · 0 评论 -
Effective C++: Item 43 -- Know how to access names in templatized base classes.
Problem: Unable to access names in templatized base classIn example:class CompanyA { public: ... void sendCleartext(const std::string& msg); void sendEncrypted(const std::string& msg); ...原创 2019-08-29 10:59:13 · 194 阅读 · 0 评论 -
Effective C++: Item 42 -- Understand the two meanings of typename
Difference between typename and class in template declarationstemplate<class T> class Widget; // uses “class”template<typename T> class Widget; // uses “typename”No difference. When de...原创 2019-08-28 11:19:10 · 216 阅读 · 0 评论 -
Effective C++: Item 41 -- Understand implicit interfaces and compile time polymorphism.
DefinitionThe world of object-oriented programming revolves around explicit interfaces and runtime polymorphism. In the world of templates and generic programming, explicit interfaces and runtime pol...原创 2019-08-27 11:27:43 · 219 阅读 · 0 评论 -
Effective C++: Item 38 -- Model “has-a” or “is-implemented-in-terms- of” through composition
DefinitionComposition is the relationship between types that arises when objects of one type contain objects of another type. Composition is also known as layering, containment, aggrega- tion, and em...原创 2019-08-22 21:32:08 · 264 阅读 · 1 评论 -
Effective C++: Item 39 -- Use private inheritance judiciously
DefinitionPrivate inheritance doesn’t mean is-a. In contrast to public inheritance, compilers will generally not convert a derived class object into a base class object if the inheritance relationshi...原创 2019-08-23 11:32:04 · 160 阅读 · 0 评论 -
Effective C++: Item 48 -- Be aware of template metaprogramming (TMP)
DefinitionTemplate metaprogramming (TMP) is the process of writing template-based C++ programs that execute during compilation. Think about that for a minute: a template metaprogram is a program writ...原创 2019-09-10 12:01:18 · 240 阅读 · 0 评论