Open main menu

Wikibooks β

Contents

PrefaceEdit

  C++ has indeed become too "expert friendly" -- Bjarne Stroustrup, The Problem with Programming, Technology Review, Nov 2006.

Stroustrup's saying is true because experts are intimately familiar with the idioms in the language. With the increase in the idioms a programmer understands, the language becomes friendlier to him or her. The objective of this open content book is to present modern C++ idioms to programmers who have moderate level of familiarity with C++, and help elevate their knowledge so that C++ feels much friendlier to them. It is designed to be an exhaustive catalog of reusable idioms that expert C++ programmers often use while programming or designing using C++. This is an effort to capture their techniques and vocabulary into a single work. This book describes the idioms in a regular format: Name-Intent-Motivation-Solution-References, which is succinct and helps speed learning. By their nature, idioms tend to have appeared in the C++ community and in published work many times. An effort has been made to refer to the original source(s) where possible; if you find a reference incomplete or incorrect, please feel free to suggest or make improvements.

The world is invited to catalog reusable pieces of C++ knowledge (similar to the book on design patterns by GoF). The goal here is to first build an exhaustive catalog of modern C++ idioms and later evolve it into an idiom language, just like a pattern language. Finally, the contents of this book can be redistributed under the terms of the GNU Free Documentation License.

Aimed toward: Anyone with an intermediate level of knowledge in C++ and supported language paradigms

More InformationEdit

Authors | Praise | Guidelines for Authors | GNU Free Documentation License

 

More C++ Idioms Recent Changes RSS 2.0




Table of ContentsEdit

Note: synonyms for each idiom are listed in parentheses.

  1. Address Of  
  2. Algebraic Hierarchy  
  3. Attach by Initialization  
  4. Attorney-Client  
  5. Barton-Nackman trick  
  6. Base-from-Member  
  7. Boost mutant  
  8. Calling Virtuals During Initialization  
  9. Capability Query  
  10. Checked delete  
  11. Clear-and-minimize  
  12. Coercion by Member Template  
  13. Computational Constructor  
  14. Concrete Data Type  
  15. Construct On First Use  
  16. Construction Tracker  
  17. Copy-and-swap  
  18. Copy-on-write  
  19. Intrusive reference counting (Counted Body)  
  20. Covariant Return Types TODO
  21. Curiously Recurring Template Pattern (CRTP)  
  22. Empty Base Optimization (EBO)  
  23. enable-if  
  24. Erase-Remove  
  25. Execute-Around Pointer  
  26. Exploding Return Type TODO
  27. Export Guard Macro TODO
  28. Expression-template  
  29. Fake Vtable TODO
  30. Fast Pimpl   TODO
  31. Final Class  
  32. Free Function Allocators 
  33. Function Object TODO
  34. Generic Container Idioms  
  35. Hierarchy Generation TODO
  36. Implicit conversions TODO
  37. Include Guard Macro  
  38. Inline Guard Macro  
  39. Inner Class  
  40. Int-To-Type  
  41. Interface Class  
  42. Iterator Pair  
  43. Making New Friends  
  44. Metafunction  
  45. Move Constructor  
  46. Multi-statement Macro  
  47. Member Detector  
  48. Named Constructor  
  49. Named External Argument TODO
  50. Named Loop (labeled loop)  
  51. Named Parameter  
  52. Named Template Parameters TODO
  53. Nifty Counter (Schwarz Counter)  
  54. Non-copyable Mixin  
  55. Non-member Non-friend Function   TODO
  56. Non-throwing swap  
  57. Non-Virtual Interface (NVI, Public Overloaded Non-Virtuals Call Protected Non-Overloaded Virtuals)  
  58. nullptr  
  59. Object Generator  
  60. Object Template TODO
  61. Parameterized Base Class (Parameterized Inheritance)  
  62. Pimpl (Handle Body, Compilation Firewall, Cheshire Cat)  
  63. Policy Clone (Metafunction wrapper)  
  64. Policy-based Design TODO
  65. Polymorphic Exception  
  66. Polymorphic Value Types   TODO
  67. Recursive Type Composition TODO
  68. Requiring or Prohibiting Heap-based Objects
  69. Resource Acquisition Is Initialization (RAII, Execute-Around Object, Scoped Locking)  
  70. Resource Return  
  71. Return Type Resolver  
  72. Runtime Static Initialization Order Idioms  
  73. Safe bool  
  74. Scope Guard  
  75. Substitution Failure Is Not An Error (SFINAE)  
  76. Shortening Long Template Names TODO
  77. Shrink-to-fit  
  78. Small Object Optimization TODO
  79. Smart Pointer  
  80. Storage Class Tracker TODO
  81. Tag Dispatching   TODO
  82. Temporary Base Class  
  83. Temporary Proxy  
  84. The result_of technique TODO
  85. Thin Template  
  86. Traits   TODO
  87. Type Erasure  
  88. Type Generator (Templated Typedef)  
  89. Type Safe Enum  
  90. Type Selection  
  91. Virtual Constructor  
  92. Virtual Friend Function  

Advanced idiomsEdit

These are some more advanced C++ idioms.

  1. Envelope Letter   TODO


Deprecated idiomsEdit

  1. Const auto_ptr  


Wikibook Development Stages
Sparse text   Developing text   Maturing text   Developed text   Comprehensive text