Commit Graph

1802 Commits (c91ea43aba3c02c75765404a3144ff6d5cd23640)

Author SHA1 Message Date
Alexey Dmitriev 34c4b9f525
Update example in F20 (#1839)
Rewrite copy vs move example to actually involve copy/move as opposite to be copy elided
4 years ago
Alexey Dmitriev b35c837477
Replace structured bindings example in ES.11 (#1840)
Closes #1655
4 years ago
Herb Sutter 72b235041b Update C.183 to use `std::byte`, closes #1823 4 years ago
Herb Sutter 369a5be424 Made `char*` advice more consistent, closes #1826 4 years ago
Herb Sutter e44a9fcbd4 Add enforcement for C.35, closes #1831 4 years ago
bgloyer 596f1ee227
ES.46 Issue 1797 - narrowing to bool (#1824)
* ES.46 Issue 1797

* spacing

* remove spaces

* dereference ptr

* spacing

* used contextual conversions to bool wording
4 years ago
bgloyer 375d452495
R.34-35 shared_ptr examples (#1808) 4 years ago
David Machaj ddc8f3e7d6
Add CP.52 and CP.53 guidelines, closes #1805, closes #1806 (#1812)
* Add CP.52 and CP.53 guidelines

* Address some feedback on CP.52

* Fix PR break caused by code line longer than 100 characters in CP.53

* Fix spelling error and one line of trailing whitespace

* Tweaks to CP.53 based on feedback
4 years ago
ash 5bbf843942
T.61 example fixes (#1813) 5 years ago
Herb Sutter 786749e60c
Clarify "concrete type" and make type category descriptions consistent (closes #1780) (#1798)
* Clarify "concrete type" and make type category descriptions consistent (closes #1780)

* markdown fixup

Co-authored-by: Jonathan Wakely <cxx@kayari.org>

* Elaborated that we can't generally add comparison operators to C structs

Co-authored-by: Sergey Zubkov <cubbi@cubbi.com>
Co-authored-by: Jonathan Wakely <cxx@kayari.org>
5 years ago
Sergey Zubkov 2feba4fbd3 make CI happier 5 years ago
Gustav Jansson 652a93ef46
[Pro.safety] Changed lettered list to a numbered (isocpp#1800) (#1801)
* Changed lettered list to a numbered (isocpp##1800)

* Added blank line for CI (isocpp##1800)
5 years ago
Sergey Zubkov bda7ff108f CI fixes 5 years ago
Herb Sutter 4c4fb37b43 Corrected enforcement of C.67 5 years ago
Herb Sutter 528cb9e832 Update C.67 and C.130 to address #1151 5 years ago
Herb Sutter 52e6263377 Add Tour2e example to C.126, closes #1794 5 years ago
Herb Sutter 402815345e Added suggestion to use a pointer member instead of a reference; closes #1783 5 years ago
Herb Sutter 03fc3a359b Closes #1791 5 years ago
Herb Sutter d93489f3d4 Applying Jonathan's suggestion for #1792 5 years ago
Alessandro Gentilini b96d861fd1
Add clarification at C.21 (#1792) 5 years ago
Marco Gartmann da97de7160
Rewrite C.164 enforcement (#1789)
Rewrite C.164 enforcement to flag non-explicit conversion operators only.
5 years ago
Juha Reunanen e2dbebed73
Do not allocate an excessive amount of memory in example code. (#1788)
This reverts commit de20b33dab.
5 years ago
Herb Sutter e583929996 Updated Con.1 to make one function a definition, closes #1785
Also fixed "arguments" -> "parameters"
5 years ago
peno2 bfa349b648
Remove 2 redundant else, according to rule F.56 (#1766)
* Remove 2 redundant else, according to rule F.56

* Remove continue from example code

Update after pull request comment.
5 years ago
5chmidti 211f6cfe3a
Fix C.127 example (#1775)
- fix for D being abstract but trying to create an object of type D in make_unique<D>()
5 years ago
Herb Sutter de20b33dab Restored `*sizeof(int)` after merging PR #1776 5 years ago
Juha Reunanen bf63aca389
A mixed bag of minor fixes, mostly related to language use (I mean English, not C++) (#1776)
* Minor comment fix

* Minor language fix

* Minor language fix

* Minor clarification

* Minor language fix

* Minor language fix

* Remove whitespace for clarity

* Make whitespace consistent (again, it wasn't the "bad" here, right?)

* Minor language fix

* Change weird formatting for emphasis

* Fix (what I believe is) a slightly distracting typo

* Minor language fix

* Suggest to highlight even security vulnerabilities as a possible outcome of concurrency errors

* Minor language fix

* Suggest to add new section for a seemingly unrelated note

* Minor language fix

* Minor language fix (not sure what this intended to say in the first place?)

* Minor language fix

* Add minor remark

* Minor language improvement

* Minor language fix

* Point out a bad example

* Minor fixes

* Minor language fix

* Add missing period (the lack of which doesn't look bad here, but does a bit in the rendered html)

* Minor language fix

* Minor language fix

* Minor typo fix (but is this what was meant?)

* Minor language improvement (?)

* Minor language fix

* Minor language fix (?)

* Add missing closing quotation mark

* Minor language fix

* Minor language fix

* Remove extra dot (or was it supposed to be three dots instead?)

* Minor language fix

* Minor language fix

* Minor language fix

* Minor language fix

* Minor language improvement

* Minor formatting improvements

* Minor improvements

* Minor language fix

* More fixing

* Add missing parentheses (did I get it right?)

* Minor language fix (?)

* Minor language fix

* Minor language fix

* Fix language (but is this what was meant in the first place?)

* Update heading to match content (in particular, the example)

* Remove superfluous whitespace

* Update also the "bad" example to use int*
5 years ago
Bill Rose 8a0053d671
Update change_speed example in P.1 to use user-defined literal syntax (#1778)
Co-authored-by: Bill Rose <neptoess@gmail.com>
5 years ago
Kie 2541e809b6
[I.9] fix typo (#1787) 5 years ago
Juha Reunanen 58f91d7cf1
C.86: Improve language just a bit (#1774) 5 years ago
Juha Reunanen 52b0aa7cdf
C.other: Improve language just a bit (#1773) 5 years ago
Juha Reunanen b933a61940
C.31: Improve language just a bit (#1772) 5 years ago
Juha Reunanen c3baa7ce8b
C.66: Improve language just a bit (#1771) 5 years ago
Juha Reunanen 652b71b2c0
F.20: Improve language just a bit (#1768) 5 years ago
Juha Reunanen 402565d74e
F.52: Improve language just a bit (#1770) 5 years ago
Sergey Zubkov 077a29ee3c CI fixes 5 years ago
Herb Sutter 7849d7e7c4 Added F.56, closes #1752 5 years ago
Herb Sutter 77b4175785 Added C.12 to discourage `const`/reference data members
Would have been nice to put this after C.9 but item numbers are dense
around here.
5 years ago
Herb Sutter 4498e078e7 Refined spec for `narrow` to cover signedness promotions, closes #1726 5 years ago
Herb Sutter c8e72981c4 Fixed misapplied edit for `<=>` 5 years ago
Herb Sutter 4f6e11940e Added bad/good example for C.89, closes #1727 5 years ago
nullptr-cpp 8bdb8fe0dc
Add '<=>' to comparison operators related rules (C.87, C.167) (#1759)
* Add '<=>' to comparison operators related rules (C.87, C.167)

C++20's three-way comparison operator should respect the same rules as other
comparison operators.

* Fix a minor typo

Co-authored-by: Jonathan Wakely <github@kayari.org>

Co-authored-by: Jonathan Wakely <github@kayari.org>
5 years ago
nullptr-cpp 5f75ea4b4b
C.63: Fix a minor typo (#1760)
In accordance with the title at line 4568, use `const&` instead of `const &`.
5 years ago
Sergey Zubkov 1dd82988d7 make CI happier 5 years ago
Herb Sutter 4f0659fb75 Added CP.coro and CP.51, closes #1756 5 years ago
Herb Sutter ccb7eff4ec CP.1: Made "bad" example consistent with now-updated "good" example 5 years ago
Martin ffeca2a254
Change comparison to use int instead of double (#1758)
This allows the example to remain simple well not misleading a beginner
such a comparison is safe. Including an epsilon comparison or something
similar would overly complicate this example.

Co-authored-by: Martin O'Shea <martin.oshea@native-instruments.com>
5 years ago
JuliusBrueggemann 1caef9a7f1 Use the same phrasing in index and actual rule 5 years ago
Herb Sutter c57e95d1c8 Clarify meaning of "inline" in F.5, closes #1731 5 years ago
Herb Sutter fa56634596 Add local lambdas and variable templates to T.61: Closes #1742 5 years ago
Herb Sutter 64ab13b3d0 Closes #1748 5 years ago
Herb Sutter a97be2d528 Addresses #1732 5 years ago
Sergey Zubkov 3e61563a0c make hunspell happy 5 years ago
Herb Sutter 75cc9a102f Improves I.24 rule wording, closes #1733 5 years ago
Herb Sutter caab79d1e9 Improving the wording of I.25 per #1734 5 years ago
Herb Sutter f46ce437e0 Slightly improved F.20 to highlight the note about const return values 5 years ago
syntroniks a5a4d0b4a2
update Enum.7 note with consistent capitalization (#1739) 5 years ago
Sergey Zubkov f6f1a49a41 typo 5 years ago
Herb Sutter 3c1991b87b Updated T.68 example 5 years ago
Herb Sutter 520ac9c695 Updated the new ES.3
Added xref, massaged summary.
5 years ago
shaneasd 627ed66ce6
Update reference to SF.7 to match text (#1735) 5 years ago
Florian Behrens c142bc9d7e
Improve example in CP.4 to not contradict F.53. (#1724)
Changed the example so that objects are not passed by reference to other thread contexts (though threads are properly synchronized).
5 years ago
peno2 b5412f5922
Add new rule ES.3 Don't repeat yourself (#1715)
* Add new rule ES.3 Don't repeat yourself

* Replace function example with more inclusive/neutral language

Add a reference to topic on libraries.
5 years ago
Sergey Zubkov 2c95a33fef travis CI fixes 5 years ago
Niels Dekker e2c0f23ce1
F.60: Remove C-style cast (T&) from example of invalid C++ (#1711) 5 years ago
Herb Sutter a6eb40c5a2 Improved F.7 lifetime note; closes #1698 5 years ago
Herb Sutter 5fdddf821d Added a justification message option for `gsl::suppress`
Closes #1703
5 years ago
Herb Sutter 53aaebb074 Updated Mozilla link and Google style guide C++ version note
Closes #1705
5 years ago
Fernando J. Iglesias García 525d8f225e
Update C.83 with swap for resource mgmt. (#1694)
* Update C.83 with swap for resource mgmt.

The swap is useful to implement assignments idiomatically (e.g. copy-swap idiom).

With the current enforcement, to non-virtual classes, very simple classes (e.g. `trivially_copyable`, a struct encapsulating an stl container) are suggested to have a swap. This suggestion can be argued wrong since for very simple classes copy-swap idiom is not efficient (the creation of a third object on assignment is not needed, which copy-swap does).

* Rework C.83 according to PR comments.
5 years ago
Sergey Zubkov 840fa592ac
merge C.150 in R.23, leaving a redirect behind (#1676) 5 years ago
hsutter dd98129f40 Fixes example in ES.105, closes #1678 5 years ago
hsutter 6ad29ce609 Fixes ES.50 example and closes #1682
Also removes the only use of `decltype` in the Guidelines, FTW.
5 years ago
Herb Sutter 55bea2089b
Remove string_span, recommend using `std::string_view`, `std:::span,<char>` or `gsl::span<char>` instead (#1680) 5 years ago
Herb Sutter 146864fe89
Cleaned up casting guidance (#1685)
The various guidelines now have consistent Enforcements.
All C-style casts are now consistently banned, including to `(void)`.
Cast to `(void`)` should be `std::ignore =` instead.
All functional-style casts are now consistently banned,  instead of
`T(x)` use `T{x}`.
5 years ago
Sergey Zubkov 86102531dc
merge C.151 into R.22, leaving a redirect behind (#1675) 5 years ago
Sergey Zubkov 30b41c32e3
merge R.30 and F.7, closes #1671 (#1674) 5 years ago
hsutter c86be249f3 Revert "Revert "Revert "Removed gsl::string_span, recommend using std::string_view, std::span<char>, or gsl::span<char> instead"""
This reverts commit 8241609450.
5 years ago
hsutter 8241609450 Revert "Revert "Removed gsl::string_span, recommend using std::string_view, std::span<char>, or gsl::span<char> instead""
This reverts commit f15ee43ad6.
5 years ago
hsutter f15ee43ad6 Revert "Removed gsl::string_span, recommend using std::string_view, std::span<char>, or gsl::span<char> instead"
This reverts commit 5257915dee.
5 years ago
hsutter 5257915dee Removed gsl::string_span, recommend using std::string_view, std::span<char>, or gsl::span<char> instead 5 years ago
Niels Dekker 0d46b2006c E.30: Remove suggestion to use `throw()`
Removed the suggestion to use `throw()` from E.30 ("Don't use exception specifications"), as it was deprecated by C++11, and is rejected by C++20.
5 years ago
hsutter 2e3f983971 Restored whitespace after "might"
Fixing previous commit where we ate the whitespace after "may" in four
places (yay regex search `might[^\s]`)
5 years ago
hsutter 75406a2db8 Remove "may" except for the month name -- closes #1542
In English, the word "may" is overloaded and ambiguous. This commit
changes it to "might" wherever possible, otherwise more specific
meanings like "can," "could," or especially "must" ("may not" -> "must
not" when that is intended).
5 years ago
David B fae4ed3768
ES.103 examples updated, addresses Issue #1656 (#1659)
* ES.103 examples updated, addresses Issue #1656

* Fix cpplint report: Res-overflow0.cpp:18:  Missing spaces around <=  [whitespace/operators] [3]
5 years ago
rjhcnf bdccf49849
added minor clarification. (#1672)
* added minor clarification.

* Update CppCoreGuidelines.md

Updated comment.

* Update CppCoreGuidelines.md
5 years ago
John McFarlane c5a771832a
Add clarifying example to SF.12
The examples in SF.12 are likely to encourage readers to always use the `""` form of `'#include` when including headers from the same project ([discussion](https://github.com/isocpp/CppCoreGuidelines/pull/1596#issuecomment-673266275)). However, in larger projects this may not always be appropriate; `<>` should be used for includes located via a header search path.

This proposed solution adds an example of the later, i.e. where `<>` is used to include a header from the same project.
5 years ago
David B bd7085e53e
Change [C++CS] refs to [SuttAlex05] Issue #1660 (#1662) 5 years ago
Sergey Zubkov 2449d5d60f E.27: make example compile, closes #1622 6 years ago
hsutter 0439326363 Closes #1579 6 years ago
hsutter 945b34d40e Closes #1574
- Add a cross-reference to C.139 and note that it doesn't matter whether
a function is declared with override or final if the whole class is
already final.
- Fix C.139 to make it clearer that it's about `final` on classes.
6 years ago
hsutter 63e2cd0ecd Closes #1585 6 years ago
Sergey Zubkov 01fa6a9bcf R.31 mark Example as Example, bad (closes #1651) 6 years ago
LE GARREC Vincent 6d17d10604
T.5: Add an example for Type erasure (#1625)
Based on :
https://www.modernescpp.com/index.php/c-core-guidelines-type-erasure-with-templates

Co-authored-by: Vincent Legarrec <vincent.legarrec@csdental.com>
6 years ago
cadenzasong d4e2281a09
removed extra space in an example in CP.2 (#1654) 6 years ago
Gabriel Dos Reis 6f50150e94
Merge pull request #1596 from apenn-msft/patch-1
SF.12: Prefer the quoted form of `#include` for files relative to the…
6 years ago
apenn-msft 94d6123c9a
relative path should be from within the same component
... files that exist at a relative path to the file containing the `#include` statement (from within the same component or project)
6 years ago
apenn-msft f458adae1f
Update CppCoreGuidelines.md
explicitly note that "file" refers to as it exists in the location of it being authored/modified.
this is to address any confusion about #including "bar.h" from foo.h based on whether bar.h is relative to foo.h at the time and location foo.h is being modified (e.g. under mylib/foo.h) versus at the time/location from which foo.h is installed to the system and included by the user (e.g. from /usr/include).
6 years ago
Hugh Macdonald d996c97809
Fix typo in SL.str.1 (#1648)
Part of SL.str.1 references replacing “const string*” with “string_view”, but the example code above shows “const string&” instead.
This changes the comment to the reference rather than pointer.
6 years ago
hsutter 12f29f2ea9 Closes #1647 6 years ago
Sergey Zubkov 895d709546 NR.5: note that example is incomplete (closes #1643) 6 years ago
al-mission-2016 c6262ea1a8
+= structured bindings mentioning; -= '\n' (#1646)
It worth to mention the *structured bindings* right in the *Reason* section.
6 years ago
hsutter 43bbde7fc9 Committing PR #1640 to main branch 6 years ago
Arthur O'Dwyer 567331ab4e
Const-qualify operator()s. NFC. (#1638)
As a general rule, `operator()` should be const-qualified.
The exceptions are few and far between.

I was actually looking for a Guideline on that subject;
I grepped for `operator()` and found that not only is there
no such Guideline yet, the doc actually contained these
places that (needlessly) violated the general rule.
6 years ago
Arthur O'Dwyer c379d3f6ea
Remove a broken example, and copyedit. (#1637)
Using `this` in a free function makes the program ill-formed;
it doesn't magically give you a `std::thread*`.
6 years ago
Sergey Zubkov 45ad5c4628 C.49: fix typo in example (closes #1642) 6 years ago
Manlio Morini 2477f275dc
Fixed broken link (Res-nonnegative) (#1641) 6 years ago
Sergey Zubkov 8b94f6ee58 I.9: update outdated note that talks of 2018 as the future, closes #1525 6 years ago
Sergey Zubkov 62be4c856d ES.28: drop broken and unnecessary example, closes #1590 6 years ago
Anthony Cassidy 9efcaf07f7
Removed anti-CamelCase comments. (#1632)
The comments were:
// ???Must we suffer CaMelcAse???
and
// ugly CaMeLcAsEvArIaBlE
6 years ago
xtofl 4867a5c2d3
Use '<thing> template' i.s.o. 'template <thing>' (#1631)
* Use '<thing> template' i.s.o. 'template <thing>'

The word 'template' is often wrongly used as an adjective to the 'thing'
it becomes when instantiated.

* Expand succinct formulation for readability

Co-authored-by: Kristoffel Pirard <kristoffel.pirard@vanhool.com>
6 years ago
rico-chet 1936cb6b44
[NL.{11,15}] Bring rules in order (#1629)
The rules NL.11 (Make literals readable) and NL.15 (Use spaces
sparingly) are placed in inverted order in the text flow, swap them.
6 years ago
Sergey Zubkov 4625c984e9 bump date 6 years ago
Sergey Zubkov 24c3993e97 fix CI, fix heading and add comment requested at today's editor's call 6 years ago
Arthur O'Dwyer d56d67969c
Expand CP.61 to talk about the general "factory" pattern. (#1621) 6 years ago
Arthur O'Dwyer e8e0d103c0
CP.1: Simplify example, show good example, expand on rationale (#1615)
"Make your code thread-safe" usually means "don't use global state."
Advice to replace global state with `thread_local` state is usually misguided.
https://quuxplusone.github.io/blog/2018/11/14/fiber-local-storage/
6 years ago
Hyuk Myeong 19f2672b9e
Adjust the spacing for consistency (#1626)
* Adjust the spacing for consistency

* Adjust the spacing for consistency-2
6 years ago
rico-chet 9960c7dd7f
[SF.10] Fix annotation of the _bad_ example (#1627)
The _bad_ example wasn't annotated as such and a perfectly fine function
name was marked bad.

Annotate the example as bad and remove the misleading function name
annotation.
6 years ago
Moritz 'Morty' Strübe f604a6b5d6
[F.36] Typo (missing s) (#1623) 6 years ago
Arthur O'Dwyer 6e0f8ace0b
Tweak one of ES.10's examples for verisimilitude. (#1611)
For some reason the trailing `e = 3` seemed more of a red flag
than anything else about this line. Let's imply that the programmer
is trying to make some constants for hexadecimal translation.
6 years ago
Dale Visser 46dadd0b16
Modified slightly impolite language (#1601)
* dumb -> inefficient
6 years ago
Yaro Shkvorets 97797870ad
code typo in R.20 (#1619) 6 years ago
apenn-msft f4c80921d6
Update CppCoreGuidelines.md 6 years ago
apenn-msft 4e61010c27
keep wording more consistent
.... if a bit more monotonous, but that's ok.
6 years ago
apenn-msft 426ac8747d
updated wording around use of <> for projects
make it more clear that using <> for external projects is just a typical example (and not the only use case for <> outside of standard headers)
6 years ago
apenn-msft bbc2f4dc5d
Merge branch 'master' into patch-1 6 years ago
Sergey Zubkov 986402298a travis CI fixes 6 years ago
Arthur O'Dwyer d45496ff5e
You should never =delete a destructor! (#1605) 6 years ago
apenn-msft 30ef5b8524
update code markdown for #include 6 years ago
apenn-msft 66792e4875
Update wording and examples for SF.12: Prefer the quoted form of `#include` for files relative
Updated wording, adjusted example, and provided a more verbose example of what can go wrong if using the wrong form.
6 years ago
apenn-msft e47463c14a
SF.12: Prefer the quoted form of `#include` for files relative to the including file
The current guidance on SF.12 can be over-applied and devolves into "always use <>" because all compilers support adding include directories to the <> search. In this case, even the current directory may be added and so it is always possible to use <> for every header. Applying the guidance then devolves into an undesirable state where <> is always used and include"" is never used.

Instead, the proposed guidance leverages and encourages the distinction between <> and "" to create an easy-to-understand rule that the original guidance hints at and that most developers already follow and understand: "" is for local headers and <> is for library and external headers.
6 years ago
Sergey Zubkov 9928c95f97 typos, wording, links (closes #1529) 6 years ago
hsutter b4bb11a833 Tweak to close #1588 6 years ago
shaneasd 040b141acf
Clarify ES.48 enforcement rule for void cast of [[nodiscard]] (#1588) 6 years ago
hsutter 1ca5545ce1 Followup to close #1586 6 years ago
Akash Mozumdar 6f01c706a8
Actually detect negative sizes by following ES.106 (#1586)
* Actually detect negative sizes by following ES.106

And don't use senseless one letter names

* fix grammar

Co-Authored-By: Johel Ernesto Guerrero Peña <johelegp@gmail.com>

Co-authored-by: Johel Ernesto Guerrero Peña <johelegp@gmail.com>
6 years ago
Sylwester Fraczek d2be4cba57
F.21 remove `;` in function definition (#1592) 6 years ago
Sergey Zubkov ab91388efd
fix mismatched anchors, closes #1569 (#1581) 6 years ago
Akash Mozumdar aea393c85c
C.180 example bugfix (#1587)
new[] needs delete[]
6 years ago
Adnn 2f0c2e5874
C.22 Fixes a mistake in the code example not making a deep copy (#1573) 6 years ago
hsutter fc383d6641 Updated #1570
Typo
6 years ago
Chris Guzak 63ceef65e3
Add SF.12, 3rd try (#1570)
* add SF.12

* add incscope to isocpp.dic to get the CI build to pass

* expand INCLUDES, update dictionary for the ci build to pass

* pr feedback

* in the same directory

* update based on feedback

* 3rd try

* PR feedback

* update lable

* Update CppCoreGuidelines.md

* Update CppCoreGuidelines.md
6 years ago
hsutter 6388b4d1ea Followup to PR 1564
Changed the two anchors back (anchors need to stay stable and don't
display visibly anyway)
Switched "non-public" back to hyphernated (to use hyphenation
consistently)
6 years ago
Hyuk Myeong ab0255b371
Add and remove hyphens to words that begin with non (#1564)
* Add hyphens to words that begins with a non

* Remove hyphens in nonpublic
6 years ago
roroberto 1429d9ec71
Added example to CP.61: Use an async() to spawn a concurrent task (#1557)
Added example to CP.61: Use an async() to spawn a concurrent task
6 years ago
Herb Sutter 6e72adc0fe
Casting away const isn't undefined behavior, but modifying a constant is (#1509)
* Casting away const isn't undefined behavior, but modifying a constant is

You can cast away `const` as much as you like, as long as you never write to variable.

* rewording for clarification
6 years ago
hsutter 2eb8ea9279 Tweaked #1516 one more time 6 years ago
hsutter fd857db583 Tweak to #1516 per editors call 6 years ago
kuzkry 745b0664c2
clarify that GSL semi-specification of some types does not reflect actual support of them (#1516) 6 years ago
hsutter dc8e49314f Tweaked PR #1553 per editors call 6 years ago
Kim Viggedal 153da17417
Merge I.2 and R.6 seem to address the same issue, (#1553)
thus I propose removing R.6 and moving some of its contents into I.2.
6 years ago
hsutter 9a4db6c1c4 Adopt the change suggested in PR #1556, just making the casing consistent the other way (lowercase) 6 years ago
hsutter b01d9e0d23 Updated MISRA entry with link, updating PR #1554 6 years ago
Mark Nelson 605a48ae03 Added two coding references (#1554)
* Added two commonly used coding guideline documents

* Update CppCoreGuidelines.md
6 years ago
hsutter f92c1c2eb3 Tweaked #1551
To adjust example comment and Enforcement per PR #1551 comments
6 years ago
Baptiste Thémine 164c0b3b5d Add code examples to CppCoreGuidelines ES.77 (#1551) 6 years ago
Hyuk Myeong 5c065f850c Fix typos (#1549)
* R.37 : it callees -> its callees
* ES.65 : a different part from the original paper
6 years ago
Sergey Zubkov c68a395830 [I.27] fix move ctor in the pimpl example (closes #1471) 6 years ago
Sergey Zubkov df94731290 update LLVM coding standards description, closes #1502 6 years ago
Bernd Ritter 778b44c2c9 Corrected link to noexcept anchor (#1559) 6 years ago
Sergey Zubkov 282ff88e57 fixes to pass travis checks 6 years ago
Sergey Zubkov 9e9950353a typos noted in comments to 2fdc696 6 years ago
shaneasd 1e371f7f86 Fix trivial recent typos (#1550) 6 years ago
Bjarne Stroustrup ad30d9ee16 Update CppCoreGuidelines.md
Clarified the enforcement of C.121 according to #1368
6 years ago
Bjarne Stroustrup 7db3ad84ff Update CppCoreGuidelines.md
REsolving #1500 with an explanatory note in the introduction.
6 years ago
Bjarne Stroustrup 2fdc6960b4 Update CppCoreGuidelines.md
Adding rule to resolve #1424
6 years ago
Bjarne Stroustrup a58ec3ee69 Update CppCoreGuidelines.md
To resolve #1356, cleaned up the text for non-rules, eliminating double negatives
6 years ago
Bjarne Stroustrup f370b1fa9e Update CppCoreGuidelines.md
Closed #1101
6 years ago
Bjarne Stroustrup b06e365c9f Modify ES.20 to address #1400 6 years ago
Bjarne Stroustrup 1fdd7e2869 testing
date change
6 years ago
Sergey Zubkov 93ab66d8da
[SF.9] singular/plural mismatch (closes #1545) 6 years ago
hsutter 54afca9318 Elaborated on PR #1539 6 years ago
Zachary Henkel 39b9ebdf86 Address items called out in Issue 1424 (#1539)
* Address items called out in Issue 1424

* Fix issues caught by CI

* Updates based on PR review
6 years ago
Zachary Henkel fc32070096 Address items called out in Issue 1418 (#1538) 6 years ago
Zachary Henkel cd478777c1 Allow return statements from case labels (#1537) 6 years ago
Mark Nelson 0363246c03 link to archived version of Collecting Shared Objects (#1530)
When a reference in the Bibliography is available online, it would seem to be nice to have a link. In this example, the original article was published in C/C++ User's Journal, with the content later ported to the DDJ web site. The DDJ site is no longer reliable, but a good copy exists in archive.org, and I've linked to it here.
6 years ago
shaneasd 56a941a7f8 Fix discussion link in C.36 (#1523) 6 years ago
johansin 3f70be9721 T.25: Fix number in exponential sequence. (#1526)
Otherwise rather suggests a quadratic growth.
6 years ago
Taewon Park ef78ef4d88 Fix wrong markdown links in E.15 (#1522)
Fixed markdown links in E.15 which direct readers to Github repository, not currently viewing page
6 years ago
Tom Lankhorst fbb2fc6bb5 Update Rper-simple example comment (#1508)
The example that is 'intended' to be faster is actually faster on clang 8 /w -O3, and marginally slower than the 'simple' example on GCC 9.1 /w -O3
http://quick-bench.com/DrXvcvhjS1zDmMkgxrzIjbMByYA
http://quick-bench.com/03VXPgDSxiMAmZMItiEA0iwTJgM
6 years ago
Elviss Strazdins 148b1064da Correct the examples to match guideline NL.16 (#1505) 6 years ago
Mike B b59bb13f2e Update CppCoreGuidelines.md (#1510)
typo
6 years ago
Simon Daester 6a004e1288 Corrected variables in Init() to mx, my. (#1501)
It doesn't make sense otherwise
6 years ago
Jonathan Wakely e6b7108dd3 Reword how C11 Annex K functions are described (#1496)
Fixes #1491
6 years ago
hsutter f1b73602c1 Closes #1470 7 years ago
beinhaerter 1a88c5a537 make the sample in Sd-factory and C.50 compileable (closes #1205, #1488) (#1489)
* make the sample in Sd-factory compileable (closes #1488)

- make the sample in Sd-factory compileable
  - fixed wrong capitalization: create/Create -> create
  - `make_shared` cannot access protected constructors, so made them public. To still have access protection introduced a protected `class Token` in each class. That token can only be created by the class itself (and derived classes) and needs to be passed to the constructor.
- changed order: `public` first, then `protected`
- same sample for C.50 and Sd-factory
- removed spurious "see Item 49.1" as it is unclear what this means

* line length

* tabs -> spaces

* spelling

* input from cubbimew

- added back in Item 49.1
- added link for items as suggested ("in [SuttAlex05](#SuttAlex05)")

* changed link to Item 49.1 to link to C.82
7 years ago
hsutter da61d9ad72 Closes #1466 7 years ago
hsutter 122cda0bd2 Closes #1451 7 years ago
Herb Sutter 5fdfb20b76
Closes #1446 (#1448)
This PR affirms that all virtual functions, *including destructors*,
should be declared exactly one of `virtual`, `override`, or `final`, and
takesa pass through the document to make the examples and guidance
consistent with that.

Of course a virtual destructor is a virtual function: It behaves
polymorphically, and it has a vtable entry that can be overwritten ==
overridden in a derived class exactly the same as any other derived
virtual override. See also [class.virtual]/7: "Even though destructors
are not inherited, a destructor in a derived class overrides a base
class destructor declared virtual; see [class.dtor] and [class.free]."

However, the following exception text currently appears in C.128:

> If a base class destructor is declared `virtual`, one should avoid
declaring derived class destructors  `virtual` or `override`. Some code
base and tools might insist on `override` for destructors, but that is
not the recommendation of these guidelines.

... but this exception is (a) not well-founded, and (b) inconsistent
with the Guidelines' practice in other examples and with the rationale a
few lines earlier for C.128 itself.

Re (a):

- The exception is overly broad: The rationale given for this exception
is entirely against marking destructors `override` (not `virtual`). So
clearly the exception to write neither keyword is too broad: At most,
the exception should be to write `virtual` rather than `override`.
- Explicit `virtual` is primarily for class users, not class authors:
The arguments given in #721 favoring this exception are from the
viewpoint of the implementation of the function (even then, the
arguments are debatable and debated). But `virtual`, `override`, and
`final` are primarily for the far larger audience of *class users and
call sites* of the function, for whom of course we should document each
declared function that is polymorphic, *especially* the destructor --
this tells calling code whether the function is safe to call through a
(smart or built-in) pointer or reference to base, which will nearly
always be the case for such types. We should not make the reader of the
code go way to look in the base classes to figure out whether a function
declared in this class is virtual or not -- the reason this Item exists
is primarily to avoid that implicit virtual antipattern via convention
and automated enforcement. For class users, all virtual functions
including destructors are equally polymorphic.

Re (b): The Guidelines already don't follow this. For instance, two
Items later (in C.130) we have this example that correctly uses
`override`:

~~~
virtual ~D() override;
~~~

... though per C.128 it should not also specify `virtual` (also fixed in
this PR).

Finally, the exception also contradicts the rationale given earlier in
the same Item.
7 years ago
beinhaerter d636a1bc5f section_sl, different stuff (#1487)
- typo "a" -> "as"
- added "???" to mark incomplete sentence
- typo "than" -> "that"
- "scanf using s" -> "scanf using %s" (same as for printf)
- added missing comma
7 years ago
beinhaerter 96c14cced6 section T, minor stuff (#1484)
- added space between two sentences
- added missing closing bracket
- typo "of" -> "or"
7 years ago
beinhaerter 796ce80102 E section, different stuff (#1480)
- E.15: "of" -> "or"
- E.27: capitalization
7 years ago
beinhaerter b80ac8bc60 ES section, different stuff (#1473)
* ES section, different stuff

- ES.26: same capitalization for all function names in example
- ES.34: fix wrong formatting (first line of example was formatted as text)
- ES.46: corrected value in comment (new value read out in debugger)
- ES.46: Capitalize Enforcement bullet points (as in other ES rules)
- ES.65: fix formatting of code after list (compare https://meta.stackexchange.com/a/34325/172717)

* review-feedback from jwakely

and:
- ES.46/ES.47: added period at end of sentence
7 years ago
beinhaerter 71a0419a1a C.145: add "see also" C.67 (#1460) 7 years ago
Chris Guzak 2895429f55 exception in SF.7 for issue 1440, allow std::literals (#1457)
* exception in SF.7 for issue 1440, allow std::literals

* PR feedback

* add UDLs to spelling dictionary

* put in alpha order
7 years ago
Werner Henze e7cdce445a SF.10: remove double `#include <vector>` from example 7 years ago
Sergey Zubkov d35d76c3e3 closes #1479 7 years ago
beinhaerter af69b85e10 same capitalization for "Technical Specification" on all occurances (#1482) 7 years ago
beinhaerter d46c678048 E.18: fix grammar (#1481) 7 years ago
beinhaerter dc72881cf3 ES.1: fixed wrong capitalization (#1468) 7 years ago
Tyler Young 5e636657d9 Fixes typo: "code based" -> "code bases" 7 years ago