mirror of
https://github.com/isocpp/CppCoreGuidelines.git
synced 2025-12-17 12:44:42 +03:00
C.32: amend merged PR per call notes. It overlaps R.3 quite a bit
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
# <a name="main"></a>C++ Core Guidelines
|
# <a name="main"></a>C++ Core Guidelines
|
||||||
|
|
||||||
June 13, 2022
|
July 13, 2022
|
||||||
|
|
||||||
|
|
||||||
Editors:
|
Editors:
|
||||||
@@ -4994,17 +4994,16 @@ There is a lot of code that is non-specific about ownership.
|
|||||||
|
|
||||||
class legacy_class
|
class legacy_class
|
||||||
{
|
{
|
||||||
foo* m_owning;
|
foo* m_owning; // Bad: change to unique_ptr<T> or owner<T*>
|
||||||
bar* m_observer;
|
bar* m_observer; // OK: keep
|
||||||
}
|
}
|
||||||
|
|
||||||
The only way to determine ownership may be to dig through the code to look for
|
The only way to determine ownership may be code analysis.
|
||||||
allocations. If a pointer or reference is owning, document it as owning.
|
|
||||||
|
|
||||||
##### Note
|
##### Note
|
||||||
|
|
||||||
Ownership should be clear in new code (and refactored legacy code) according to [R.20](#Rr-owner) for owned
|
Ownership should be clear in new code (and refactored legacy code) according to [R.20](#Rr-owner) for owning
|
||||||
pointers and [R.3](#Rr-ptr) for non-owned pointers. References should never own [R.4](#Rr-ref).
|
pointers and [R.3](#Rr-ptr) for non-owning pointers. References should never own [R.4](#Rr-ref).
|
||||||
|
|
||||||
##### Enforcement
|
##### Enforcement
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user