Skip to content

关于本章

本章总结C++的idiom,主要参考:

1、wikibooks More C++ Idioms

2、cppreference Idioms

wikibooks More 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(一个语言的专家往往非常熟悉这个语言的idiom). 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

What is idiom

Theory\Design-pattern\Software-design-patternClassification and list段中的描述是:

The most basic and low-level patterns are often called idioms. They usually apply only to a single programming language.

分类

本章主要基于programming paradigm来对idiom进行分类,另外还包含一些专题。

C++ idiom非常多,其实很难进行分类,有些idiom可以归入多种类别中。