Clean up and add example for C.32 - raw pointers#1909
Clean up and add example for C.32 - raw pointers#1909hsutter merged 10 commits intoisocpp:masterfrom
Conversation
| ??? | ||
| class LegacyClass | ||
| { | ||
| Foo* m_owningPtr; |
There was a problem hiding this comment.
I suspect both LegacyClass and m_owningPtr` run afoul of NL.10
|
Editors call: Owning raw pointers and references are already banned under R.3 and R.4. Sometimes they do get used, so we think owning references should still be mentioned. Otherwise, the PR looks good, if you can please restore the owning references we can approve it. |
|
How about extending the example to something like |
* F.16 ("in" parameters): Move Matrix example to F.20 (return values) (isocpp#1922)
The `Matrix` example and the notes about assignment appear off-topic in rule F.16, as F.16 is specifically about "in" parameters.
With help from Sergey Zubkov.
* SL.io.50 (Avoid `endl`): Mention string streams (isocpp#1920)
Explicitly mentioned string streams as `endl` insertions into string streams do actually occur in the wild.
With help from Sergey Zubkov.
* Extended E.16 to include copy ctor for exception type, closes isocpp#1921
* Fix GitHub Actions build warnings, Marker style should be `*` (isocpp#1925)
* restored reference
* Added references to note
Co-authored-by: Niels Dekker <N.Dekker@lumc.nl>
Co-authored-by: Herb Sutter <herb.sutter@gmail.com>
Is it enough just to leave examples for pointers? It is true that when working with legacy code, ownership of member pointers is often not clear and requires some digging. Owning member pointers was a common practice in older C++. That is not true for references. Owning references have always been a bad idea. Why would anyone have used an owning |
Master c32 merge
|
I merge the latest so the diff's are clean now. Anything more on this one? |
|
Editors call: Thanks! |
Added a simple example for C.32: If a class has a raw pointer (
T*), consider whether it might be owningAlso removed mentioning of owning references. I think owning referecnce are rare and generally not a problem in legacy code.
R.3 gives an exception for legacy code to have owing raw pointers but R.4 does not for owning references. If we want to keep the owing references C.33 should probably be updated to delete owing references.