Library Organization and Containers(Chapter 16 of The C++ Programming Language)
转载[1] Use standard library facilities to maintain portability;
[2] Don’t try to redefine standard library facilities;
[3] Don’t believe that the standard library is best for everything.
[4] When building a new facility, consider whether it can be presented within the framework offered by the standard library;
[5] Remember that standard library facilities are defined in namespace std;
[6] Declare standard library facilities by including its header, not by explicit declaration;
[7] Take advantage of late abstraction;
[8] Avoid fat interfaces;
[9] Prefer algorithms with reverse iterators over explicit loops dealing with reverse order;
[10] Use base() to extract an iterator from a reverse_iterator;
[11] Pass containers by reference;
[12] Use iterator types, such as list<char>::iterator, rather than pointers to refer to elements of a container;
[13] Use const iterators where you don’t need to modify the elements of a container;
[14] Use at(), directly or indirectly, if you want range checking;
[15] Use push_back() or resize() on a container rather than realloc() on an array;
[16] Don’t use iterators into a resized vector;
[17] Use reserve() to avoid invalidating iterators;
[18] When necessary, use reserve() to make performance predictable;
本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。
上一篇:Threads(Chapter 3 of Concurrent Programming on Windows)
下一篇:Class Hierarchies(Chapter 15 of The C++ Programming Language)
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
51c视觉~合集16视觉
-
Utilities(Chapter 4 of The C++ Stardard Library)
[代码]
C++ #include ios 干货