Scott Meyers
Table of contents :
Effective STL: 50 Specific Ways to Improve Your Use of Standard Template Library……Page 1
Content……Page 2
1. Choose your containers with care……Page 6
2. Beware illusion of container-independent code……Page 9
3. Make copying cheap & correct for objects in containers……Page 14
4. Call empty instead of checking size() against zero……Page 16
5. Prefer range member functions to their single-element counterparts……Page 17
6. Be alert for C++’s most vexing parse……Page 25
7. When using containers of newed pointers, remember to delete pointers before container is destroyed……Page 27
8. Never create containers of auto_ptrs……Page 32
9. Choose carefully among erasing options……Page 34
10. Be aware of allocator conventions & restrictions……Page 39
11. Understand legitimate uses of custom allocators……Page 45
12. Have realistic expectations about thread safety of STL containers……Page 48
13. Prefer vector & string to dynamically allocated arrays……Page 53
14. Use reserve to avoid unnecessary reallocations……Page 55
15. Be aware of variations in string implementations……Page 57
16. Know how to pass vector & string data to legacy APIs…….Page 62
17. Use “swap trick” to trim excess capacity……Page 65
18. Avoid using vector……Page 67
19. Understand difference between equality & equivalence……Page 70
20. Specify comparison types for associative containers of pointers……Page 74
21. Always have comparison functions return false for equal values……Page 78
22. Avoid in-place key modification in set & multiset……Page 81
23. Consider replacing associative containers with sorted vectors……Page 86
24. Choose carefully between map::operator[] & map-insert when efficiency is important……Page 92
25. Familiarize yourself with nonstandard hashed containers……Page 96
26. Prefer iterator to const iterator, reverse_iterator & const_reverse_iterator……Page 100
27. Use distance & advance to convert container’s const_iterators to iterators……Page 103
28. Understand how to use reverse_iterator’s base iterator……Page 106
29. Consider istreambuf_iterators for character-by-character input……Page 108
30. Make sure destination ranges are big enough……Page 111
31. Know your sorting options……Page 116
32. Follow remove-like algorithms by erase if you really want to remove something……Page 121
33. Be wary of remove-like algorithms on containers of pointers……Page 125
34. Note which algorithms expect sorted ranges……Page 128
35. Implement simple case-insensitive string comparisons via mismatch or lexicographical compare……Page 131
36. Understand proper implementation of copy_if……Page 135
37. Use accumulate or for_each to summarize ranges……Page 137
38. Design functor classes for pass-by-value……Page 143
39. Make predicates pure functions……Page 146
40. Make functor classes adaptable……Page 149
41. Understand reasons for ptr_fun, mem_fun & mem_fun_ref……Page 153
42. Make sure less means operator
Reviews
There are no reviews yet.