Preface edit

  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 them. 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 Information edit

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


More C++ Idioms Recent Changes RSS 2.0

Table of Contents edit

Note: synonyms for each idiom are listed in parentheses.

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

Advanced idioms edit

These are some more advanced C++ idioms.

  1. Envelope Letter   TODO

Deprecated idioms edit

  1. Const auto_ptr  

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