You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CppCoreGuidelines.md
+16-6Lines changed: 16 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -6522,10 +6522,10 @@ By itself, `cout_my_class` would be OK, but it is not usable/composabe with code
6522
6522
6523
6523
There are strong and vigorous conventions for the meaning most operators, such as
6524
6524
6525
-
* comparisons (`==`, `!=`, '<', `<=`, `>`, and `>=`),
6525
+
* comparisons (`==`, `!=`, '<', `<=`, `>`, and `>=`)
6526
6526
* arithmetic operations (`+`, `-`, `*`, `/`, and `%`)
6527
6527
* access operations (`.`, `->`, unary `*`, and `[]`)
6528
-
* assignment and initialization (`=`)
6528
+
* assignment (`=`)
6529
6529
6530
6530
Don't define those unconventionally and don't invent yur own names for them.
6531
6531
@@ -6942,11 +6942,21 @@ We can fix that problem by making ownership explicit:
6942
6942
6943
6943
##### Exceptions
6944
6944
6945
-
A major class of exception is legacy code, especially code that must remain compilable as C.
6945
+
A major class of exception is legacy code, especially code that must remain compilable as C or interface with C and C-style C++ through ABIs.
6946
6946
The fact that there are billions of lines of code that violate this rule against owning `T*`s cannot be ignored.
6947
-
This code cannot all be rewritten (ever assuming good code transformation software).
6948
-
This problem cannot be solved (at scale) by transforming all owning pointers to `unique_ptr`s and `shared_ptr`s, partly because we need/use owning "raw pointers" in the implementation of our fundamental resource handles. For example, common `vector` implementations have one owning pointer and two non-owning pointers.
6949
-
Also, many ABIs (and essentially all interfaces to C code) use `T*`s, some of them owning, and these cannot be simply annotated with `owner` because they need to remain compilable as C (although this would be a rare good use for a macro, that expands to `owner` in C++ mode only).
6947
+
We'd love to see program transformation tools turning 20-year-old "legacy" code into shiny modern code,
6948
+
we encourage the development, deploymenta and use of such tools,
6949
+
we hope the guidelines wil help the development of such tools,
6950
+
and we even contributed (and contribute) to the research and developemnt in this area.
6951
+
However, it will take time: "legacy code" is generated faster than we can renovate old code, and so it will be for a few years.
6952
+
6953
+
This code cannot all be rewritten (ever assuming good code transformation software), especially not soon.
6954
+
This problem cannot be solved (at scale) by transforming all owning pointers to `unique_ptr`s and `shared_ptr`s,
6955
+
partly because we need/use owning "raw pointers" as well as simple pointers in the implementation of our fundamental resource handles.
6956
+
For example, common `vector` implementations have one owning pointer and two non-owning pointers.
6957
+
Many ABIs (and essentially all interfaces to C code) use `T*`s, some of them owning.
6958
+
Some interfaces cannot be simply annotated with `owner` because they need to remain compilable as C
6959
+
(although this would be a rare good use for a macro, that expands to `owner` in C++ mode only).
0 commit comments