├── cpp_core_guidelines_logo_text.png
├── images
├── param-passing-advanced.png
└── param-passing-normal.png
├── README.md
├── LICENSE
└── CONTRIBUTING.md
/cpp_core_guidelines_logo_text.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lynnboy/CppCoreGuidelines-zh-CN/HEAD/cpp_core_guidelines_logo_text.png
--------------------------------------------------------------------------------
/images/param-passing-advanced.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lynnboy/CppCoreGuidelines-zh-CN/HEAD/images/param-passing-advanced.png
--------------------------------------------------------------------------------
/images/param-passing-normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lynnboy/CppCoreGuidelines-zh-CN/HEAD/images/param-passing-normal.png
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](https://isocpp.github.io/CppCoreGuidelines)
2 |
3 | # [C++ 核心指导方针](http://lynnboy.github.io/CppCoreGuidelines-zh-CN/CppCoreGuidelines)
4 |
5 | >"Within C++ is a smaller, simpler, safer language struggling to get out."
6 | >-- Bjarne Stroustrup
7 |
8 | [《C++ 核心指导方针》(The C++ Core Guidelines)](CppCoreGuidelines-zh-CN.md),与 C++ 语言本身一样,是由 Bjarne Stroustrup 领导的协作项目。
9 | 该指导方针是许多组织和团体之间耗费了大量人年的探讨和设计的心血成果。它们的设计着眼于普遍的适用性并鼓励广泛采纳,
10 | 但您也可以对其进行随意的复制和修改,以满足您的团体组织自身的需要。
11 |
12 | ## 起步
13 |
14 | 指导方针内容见 [CppCoreGuidelines](CppCoreGuidelines-zh-CN.md)。该文档为 [GH 风格 MarkDown 格式](https://github.github.com/gfm/)。我们有意维持文档简单,(英文原版)基本上是 ASCII,以便于进行诸如语言翻译和格式转换之类的自动化后处理。
15 | 编写者们还维护了[一个适于浏览的版本](https://lynnboy.github.io/CppCoreGuidelines-zh-CN/CppCoreGuidelines-zh-CN)。请注意它由人工集成,因而可能略晚于 master 分支的版本。
16 | [英文原版](http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines)。
17 |
18 | 这些指导方针是持续不断演进的文档,并且没有严格的“发布”节奏。Bjarne Stroustrop 定期评审文档并增加导言部分的版本号。[增加版本号的签入](https://github.com/isocpp/CppCoreGuidelines/releases) 都在 git 中打了标签。
19 |
20 | 其中有不少都用到了纯头文件的 Guidelines Support Library(指导方针支持库)。有一个实现在 [GSL:Guidelines Support Library](https://github.com/Microsoft/GSL)。
21 |
22 | ## 背景和领域
23 |
24 | 这个指导方针的目标是帮助人们更有效地运用现代 C++ 语言。所谓“现代”的含义是指 C++11 和更新的版本。
25 | 换句话说,如果你从现在开始算起,五年后你的代码看起来是怎么样的?十年呢?
26 |
27 | 指南所关注的是一些相对比较高层次的问题,比如接口,资源管理,内存管理,以及并发等等。这样的规则会对应用的架构
28 | 以及程序库的设计都造成影响。如果遵循这些规则,代码将会是静态类型安全的,没有资源泄露,并且能够捕捉到比当今的代码
29 | 通常所能捕捉到的多得多的编程逻辑错误。还能更快速地运行——你不必牺牲程序的正确性。
30 |
31 | 我们对于如命名约定和缩进风格一类的低层次的问题不那么关注。当然,对程序员有帮助的任何话题都是可接受的。
32 |
33 | 我们最初的规则集合强调的是(各种形式的)安全性以及简单性,它们有些过于严格了。我们预期将会引入更多的例外情况,
34 | 以便使它们更好地适应现实世界的需要。我们也需要更多的规则。
35 |
36 | 您可能会发现,有的规则与您的预期相反,甚至是与您的经验相违背。其实如果我们没建议您在任何方面改变您的编码风格,
37 | 那其实就是我们的失败。请您尝试验证或者证伪这些规则吧!尤其是,我们十分期望让一些规则能够建立在真实的测量数据上,
38 | 或者是一些更好的例子之上。
39 |
40 | 您可能会觉得一些规则很显然,甚至没有什么价值。但请记住,一份指导方针的目的之一就在于帮助那些经验不足的,或来自其他
41 | 背景或使用其他语言的人,能够迅速行动起来。
42 |
43 | 指导方针中的规则有意设计成可以由分析工具提供支持的。违反规则的代码会打上标记,以引用(或者链接)到相关的规则。
44 | 您在开始编码前并不需要记住所有这些规则。
45 |
46 | 这些规则都是为了逐步引入一个代码库而设计的。我们计划建立这样的工具,并希望其他人也能提供它们。
47 |
48 | ## 贡献与授权
49 |
50 | 十分欢迎大家提出意见和改进建议。随着我们的知识增长,随着语言和可用的程序库的改进,我们计划对这份文档不断进行修改和扩充。
51 | 更多细节请见 [CONTRIBUTING](./CONTRIBUTING.md) 和 [LICENSE](./LICENSE)。
52 |
53 | 感谢 [DigitalOcean](https://www.digitalocean.com/?refcode=32f291566cf7&utm_campaign=Referral_Invite&utm_medium=Referral_Program&utm_source=CopyPaste) 存放标准 C++ 基金会网站。
54 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) Standard C++ Foundation and its contributors
2 |
3 | Standard C++ Foundation grants you a worldwide, nonexclusive, royalty-free,
4 | perpetual license to copy, use, modify, and create derivative works from this
5 | project for your personal or internal business use only. The above copyright
6 | notice and this permission notice shall be included in all copies or
7 | substantial portions of the project. This license does not grant permission
8 | to use the trade names, trademarks, service marks, or product names of the
9 | licensor, except as required for reasonable and customary use in describing
10 | the origin of the project.
11 |
12 | Standard C++ Foundation reserves the right to accept contributions to the
13 | project at its discretion.
14 |
15 | By contributing material to this project, you grant Standard C++ Foundation,
16 | and those who receive the material directly or indirectly from Standard C++
17 | Foundation, a perpetual, worldwide, non-exclusive, royalty-free, irrevocable,
18 | transferrable license to reproduce, prepare derivative works of, publicly
19 | display, publicly perform, and distribute your contributed material and such
20 | derivative works, and to sublicense any or all of the foregoing rights to third
21 | parties for commercial or non-commercial use. You also grant Standard C++
22 | Foundation, and those who receive the material directly or indirectly from
23 | Standard C++ Foundation, a perpetual, worldwide, non-exclusive, royalty-free,
24 | irrevocable license under your patent claims that directly read on your
25 | contributed material to make, have made, use, offer to sell, sell and import
26 | or otherwise dispose of the material. You warrant that your material is your
27 | original work, or that you have the right to grant the above licenses.
28 |
29 | THE PROJECT IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
32 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
33 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
34 | OUT OF OR IN CONNECTION WITH THE PROJECT OR THE USE OR OTHER DEALINGS IN THE
35 | PROJECT.
36 |
37 | If you believe that anything in the project infringes your copyright, please
38 | contact us at admin@isocpp.org with your contact information and a detailed
39 | description of your intellectual property, including a specific URL where you
40 | believe your intellectual property is being infringed.
41 |
42 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | ## Contributing to the C++ Core Guidelines
2 |
3 | >"Within C++ is a smaller, simpler, safer language struggling to get out."
4 | >-- Bjarne Stroustrup
5 |
6 | The C++ Core Guidelines are a collaborative effort led by Bjarne Stroustrup, much like the C++ language itself. They are the result of many
7 | person-years of discussion and design across a number of organizations. Their design encourages general applicability and broad adoption but
8 | they can be freely copied and modified to meet your organization's needs.
9 |
10 | We encourage contributions to the C++ Core Guidelines in a number of ways:
11 | - **Individual feedback** Are you a developer who is passionate about your code? Join the discussion in
12 | [Issues](https://github.com/isocpp/CppCoreGuidelines/issues). We want to know which rules resonate with you and which don't. Were any rules
13 | inordinately difficult to apply? Does your compiler vendor's Guidelines Support Library (e.g.,
14 | [Microsoft's implementation of the GSL](https://github.com/microsoft/gsl)) suit your needs in adopting these guidelines?
15 | - **Organizational adoption** While the guidelines are designed to be broadly adoptable they are also intended to be modified to fit your
16 | organization's particular needs. We encourage your organization to fork this repo and create your own copy of these guidelines with changes
17 | that reflect your needs. We suggest that you make it clear in the title of your guidelines that these are your organization's fork of the
18 | guidelines and that you provide a link back to the original set of [guidelines](https://github.com/isocpp/CppCoreGuidelines). And if any of
19 | your local changes are appropriate to pull back into the original guidelines, please open an
20 | [Issue](https://github.com/isocpp/CppCoreGuidelines/issues) which can lead to a pull request.
21 | - **Maintain the Guidelines** The C++ Core Guidelines were created from a wealth of knowledge spread across a number of organizations
22 | worldwide. If you or your organization is passionate about helping to create the guidelines, consider becoming an editor or maintainer. If
23 | you're a C++ expert who is serious about participating, please
24 | [email coreguidelines@isocpp.org](mailto:coreguidelines@isocpp.org?subject=Maintain%20the%20C++%20Code%20Guidelines).
25 |
26 | ## Contributor License Agreement
27 | By contributing content to the C++ Core Guidelines (i.e., submitting a pull request for inclusion in this repository) you agree with the
28 | [Standard C++ Foundation](https://isocpp.org/about) [Terms of Use](https://isocpp.org/home/terms-of-use), especially all of the terms specified
29 | regarding Copyright and Patents.
30 | - You warrant that your material is original, or you have the right to contribute it.
31 | - With respect to the material that you own, you grant a worldwide, non-exclusive, irrevocable, transferable, and royalty-free license to your contributed
32 | material to Standard C++ Foundation to display, reproduce, perform, distribute, and create derivative works of that material for commercial or
33 | non-commercial use. With respect to any other material you contribute, such material must be under a license sufficient to allow Standard C++ Foundation
34 | to display, reproduce, perform, distribute, and create derivative works of that material for commercial or non-commercial use.
35 | - You agree that, if your contributed material is subsequently reflected in the ISO/IEC C++ standard in any form, it will be subject to all ISO/IEC JTC
36 | 1 policies including [copyrights](http://www.iso.org/iso/home/policies.htm),
37 | [patents](http://www.iso.org/iso/home/standards_development/governance_of_technical_work/patents.htm), and
38 | [procedures](http://www.itscj.ipsj.or.jp/sc29/29w7proc.htm); please direct any questions about these policies to the
39 | [ISO Central Secretariat](http://www.iso.org/iso/home/about.htm).
40 |
41 |
42 | ## Pull requests
43 |
44 | We welcome pull requests for scoped changes to the guidelines--bug fixes in
45 | examples, clarifying ambiguous text, etc. Significant changes should first be
46 | discussed in the [Issues](https://github.com/isocpp/CppCoreGuidelines/issues)
47 | and the Issue number must be included in the pull request. For
48 | guideline-related changes, please specify the rule number in your Issue and/or
49 | Pull Request.
50 |
51 | Changes should be made in a child commit of a recent commit in the master
52 | branch. If you are making many small changes, please create separate PRs to
53 | minimize merge issues.
54 |
55 | ### Document Style Guidelines
56 |
57 | Documents in this repository are written in an unspecific flavor of Markdown,
58 | which leaves some ambiguity for formatting text. We ask that pull requests
59 | maintain the following style guidelines, though we are aware that the document
60 | may not already be consistent.
61 |
62 | #### Indentation
63 |
64 | Code and nested text should use multiples of 4 spaces of indentation, and no
65 | tab characters, like so:
66 |
67 | void func(const int x)
68 | {
69 | std::cout << x << '\n';
70 | }
71 |
72 | #### Code Blocks
73 |
74 | Please use 4-space indentation to trigger code parsing, rather than [fenced code blocks](https://help.github.com/articles/github-flavored-markdown/#fenced-code-blocks) or any other style, like so:
75 |
76 | This is some document text, with an example below:
77 |
78 | void func()
79 | {
80 | std::cout << "This is code.\n";
81 | }
82 |
83 | #### Document style decisions
84 |
85 | We've discussed and made decisions on a number of document style. Please do not open PRs that revisit these stylistic points:
86 |
87 | - The CppCoreGuidelines.md file is a single GH-flavored Markdown file. It is not split into separate chapters.
88 | - We do not use syntax highlighting in the Core Guidelines. See PRs #33, #96, #328, and #779. If you want syntax highlighting you
89 | can either view the "pretty" version at http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines or do your own post-processing.
90 | - We're sticking with the ASCII character set. We do not use Unicode em-dashes, Unicode spaces, or pretty quotes. Lots of people edit this file with their various text editors. ASCII is simple and universally understood.
91 |
92 | ### Update dictionary
93 |
94 | Code samples in the guidelines are run through a spelling checker. Be sure to add new class and variable names to [scripts/hunspell/isocpp.dic](https://github.com/isocpp/CppCoreGuidelines/blob/master/scripts/hunspell/isocpp.dic).
95 |
96 | ### Miscellaneous
97 |
98 | To avoid line-ending issues, please set `autocrlf = input` and `whitespace = cr-at-eol` in your git configuration.
99 |
--------------------------------------------------------------------------------