More C++ Idioms

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 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 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. 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. Intrusive reference counting (Counted Body)  
  21. Covariant Return Types TODO
  22. Curiously Recurring Template Pattern (CRTP)  
  23. Deprecate and Delete TODO
  24. Empty Base Optimization (EBO)  
  25. enable-if  
  26. Erase-Remove  
  27. Execute-Around Pointer  
  28. Exploding Return Type TODO
  29. Export Guard Macro TODO
  30. Expression-template  
  31. Fake Vtable TODO
  32. Fast Pimpl   TODO
  33. Final Class  
  34. Free Function Allocators 
  35. Function Object TODO
  36. Function Poisoning TODO
  37. Generic Container Idioms  
  38. Hierarchy Generation TODO
  39. Implicit conversions TODO
  40. Include Guard Macro  
  41. Inline Guard Macro  
  42. Inner Class  
  43. Int-To-Type  
  44. Interface Class  
  45. Iterator Pair  
  46. Making New Friends  
  47. Metafunction  
  48. Move Constructor  
  49. Multi-statement Macro  
  50. Member Detector  
  51. Named Constructor  
  52. Named External Argument TODO
  53. Named Loop (labeled loop)  
  54. Named Parameter  
  55. Named Template Parameters TODO
  56. Nifty Counter (Schwarz Counter)  
  57. Non-copyable Mixin  
  58. Non-member Non-friend Function   TODO
  59. Non-throwing swap  
  60. Non-Virtual Interface (NVI, Public Overloaded Non-Virtuals Call Protected Non-Overloaded Virtuals)  
  61. nullptr  
  62. Object Generator  
  63. Object Template TODO
  64. Parameterized Base Class (Parameterized Inheritance)  
  65. Pimpl (Handle Body, Compilation Firewall, Cheshire Cat)  
  66. Policy Clone (Metafunction wrapper)  
  67. Policy-based Design TODO
  68. Polymorphic Exception  
  69. Polymorphic Value Types   TODO
  70. Recursive Type Composition TODO
  71. Requiring or Prohibiting Heap-based Objects
  72. Resource Acquisition Is Initialization (RAII, Execute-Around Object, Scoped Locking)  
  73. Resource Return  
  74. Return Type Resolver  
  75. Runtime Static Initialization Order Idioms  
  76. Safe bool  
  77. Scope Guard  
  78. Substitution Failure Is Not An Error (SFINAE)  
  79. Shortening Long Template Names TODO
  80. Shrink-to-fit  
  81. Small Object Optimization TODO
  82. Smart Pointer  
  83. Storage Class Tracker TODO
  84. Tag Dispatching   TODO
  85. Temporary Base Class  
  86. Temporary Proxy  
  87. The result_of technique TODO
  88. Thin Template  
  89. Thread-Safe Interface TODO
  90. Traits   TODO
  91. Type Erasure  
  92. Type Generator (Templated Typedef)  
  93. Type Safe Enum  
  94. Type Selection  
  95. Virtual Constructor  
  96. 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