A curated list of Modern C++ idioms.
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 CppIdioms 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.
- Variadic Argument Macro
- Multi Statement Macro
- Name Macro
- INTSIZEOF
- offset_of
- Flexible Array
- Virtual Friend Function
- Making New Friend
- addressof
- Policy Base Design
- Require or Prohibiting Heap Object
- SFINAE (Substitution Failure Is Not An Error)
- enable_if
- Type Selection
- Identity
- Return Type Resolver
- reference_wrapper
- Two Phase Constructor
- Calling Virtuals during Initialization
- Dynamic Creation
- RTTI (Run-Time Type Identification)
- Capability Query
- Coercion by Member Template
- Covariant Return Type
- Attach by Initialization
- Clear and Minimize
- Placement New
- Generic Container idioms
- Meta Function
- Policy Clone
- Safe bool
- Thin Template
- RVO (Return Value Optimization), NRVO (Named RVO)
- Checked Delete
- Temporary Proxy
- Traits
- int to Type
- Pimpl
- Empty Class
- Tag Dispatching
- Type List
- Exception Safety
- Trivial
This software is provided under the MIT License, more information can be found in the license file.
Contributions are always welcome, either reporting issues/bugs or forking the repository and then issuing pull requests when you have completed some additional coding that you feel will be beneficial to the main project. If you are interested in contributing in a more dedicated capacity, then please contact me.
You can contact me via Facebook at http://www.facebook.com/utilForever. I am always happy to answer questions or help with any issues you might have, and please be sure to share any additional work or your creations with me, I love seeing what other people are making.