More C++ Idioms
Preface
| 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 Information
↑Jump back a sectionTable of Contents
Note: synonyms for each idiom are listed in parentheses.
- Adapter Template
- 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
- Const auto_ptr
- Construct On First Use
- Construction Tracker
- Copy-and-swap
- Copy-on-write
- Intrusive reference counting (Counted Body)
- Curiously Recurring Template Pattern
- Non-intrusive reference counting (Detached Counted Body)
- Empty Base Optimization
- enable-if
- Envelope Letter
- Erase-Remove
- Execute-Around Pointer
- Exploding Return Type
- Export Guard Macro
- Expression-template
- Fake Vtable
- Fast Pimpl
- Final Class
- Free Function Allocators
- Function Object
- Generic Container Idioms
- Hierarchy Generation
- 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
- Named Loop (labeled loop)
- Named Parameter
- Named Template Parameters
- Nifty Counter (Schwarz Counter)
- Non-copyable Mixin
- Non-member Non-friend Function
- Non-throwing swap
- Non-Virtual Interface (Public Overloaded Non-Virtuals Call Protected Non-Overloaded Virtuals)
- nullptr
- Object Generator
- Object Template
- Parameterized Base Class (Parameterized Inheritance)
- Pimpl (Handle Body, Compilation Firewall, Cheshire Cat)
- Policy Clone (Metafunction wrapper)
- Policy-based Design
- Polymorphic Exception
- Polymorphic Value Types
- Recursive Type Composition
- 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
- Shrink-to-fit
- Small Object Optimization
- Smart Pointer
- Storage Class Tracker
- Tag Dispatching
- Temporary Base Class
- Temporary Proxy
- The result_of technique
- Thin Template
- Traits
- Type Erasure
- Type Generator (Templated Typedef)
- Type Safe Enum
- Type Selection
- Virtual Constructor
- Virtual Friend Function