More C++ Idioms
Preface
[edit | edit source]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 | edit source]Authors | Praise | Guidelines for Authors | GNU Free Documentation License
Table of Contents
[edit | edit source]Note: synonyms for each idiom are listed in parentheses.
- Acyclic Visitor Pattern TODO
- Address Of
- Algebraic Hierarchy
- Attach by Initialization
- Attorney-Client
- Barton-Nackman trick
- Base-from-Member
- Boost mutant
- Calling Virtuals During Initialization
- Capability Query
- Checked delete
- Clear-and-minimize
- Coercion by Member Template
- Computational Constructor
- Concrete Data Type
- Construct On First Use
- Construction Tracker
- Copy-and-swap
- Copy-on-write
- Thread-safe Copy-on-write
- Intrusive reference counting (Counted Body)
- Covariant Return Types TODO
- Curiously Recurring Template Pattern (CRTP)
- Deprecate and Delete TODO
- Empty Base Optimization (EBO)
- enable-if
- Erase-Remove
- Execute-Around Pointer
- Exploding Return Type TODO
- Export Guard Macro TODO
- Expression-template
- Fake Vtable TODO
- Fast Pimpl TODO
- Final Class
- Free Function Allocators
- Function Object TODO
- Function Poisoning TODO
- Generic Container Idioms
- Hierarchy Generation TODO
- Implicit conversions TODO
- Include Guard Macro
- Inline Guard Macro
- Inner Class
- Int-To-Type
- Interface Class
- Iterator Pair
- Making New Friends
- Metafunction
- Move Constructor
- Multi-statement Macro
- Member Detector
- Named Constructor
- Named External Argument TODO
- Named Loop (labeled loop)
- Named Parameter
- Named Template Parameters TODO
- Nifty Counter (Schwarz Counter)
- Non-copyable Mixin
- Non-member Non-friend Function TODO
- Non-throwing swap
- Non-Virtual Interface (NVI, Public Overloaded Non-Virtuals Call Protected Non-Overloaded Virtuals)
- nullptr
- Object Generator
- Object Template TODO
- Parameterized Base Class (Parameterized Inheritance)
- Pimpl (Handle Body, Compilation Firewall, Cheshire Cat)
- Policy Clone (Metafunction wrapper)
- Policy-based Design TODO
- Polymorphic Exception
- Polymorphic Value Types
- Recursive Type Composition TODO
- Requiring or Prohibiting Heap-based Objects
- Resource Acquisition Is Initialization (RAII, Execute-Around Object, Scoped Locking)
- Resource Return
- Return Type Resolver
- Runtime Static Initialization Order Idioms
- Safe bool
- Scope Guard
- Substitution Failure Is Not An Error (SFINAE)
- Shortening Long Template Names TODO
- Shrink-to-fit
- Small Object Optimization TODO
- Smart Pointer
- Storage Class Tracker TODO
- Tag Dispatching
- Temporary Base Class
- Temporary Proxy
- The result_of technique TODO
- Thin Template
- Thread-Safe Interface TODO
- Traits
- Type Erasure
- Type Generator (Templated Typedef)
- Type Safe Enum
- Type Selection
- Virtual Constructor
- Virtual Friend Function
Advanced idioms
[edit | edit source]These are some more advanced C++ idioms.
- Envelope Letter TODO
Deprecated idioms
[edit | edit source]