Skip to content

Commit 5547b43

Browse files
a few issues
1 parent df9aca5 commit 5547b43

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

CppCoreGuidelines.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6522,10 +6522,10 @@ By itself, `cout_my_class` would be OK, but it is not usable/composabe with code
65226522

65236523
There are strong and vigorous conventions for the meaning most operators, such as
65246524

6525-
* comparisons (`==`, `!=`, '<', `<=`, `>`, and `>=`),
6525+
* comparisons (`==`, `!=`, '<', `<=`, `>`, and `>=`)
65266526
* arithmetic operations (`+`, `-`, `*`, `/`, and `%`)
65276527
* access operations (`.`, `->`, unary `*`, and `[]`)
6528-
* assignment and initialization (`=`)
6528+
* assignment (`=`)
65296529

65306530
Don't define those unconventionally and don't invent yur own names for them.
65316531

@@ -6942,11 +6942,21 @@ We can fix that problem by making ownership explicit:
69426942

69436943
##### Exceptions
69446944

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.
69466946
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).
69506960

69516961
##### Note
69526962

0 commit comments

Comments
 (0)