mirror of
https://github.com/isocpp/CppCoreGuidelines.git
synced 2024-03-22 13:30:58 +08:00
parent
b87d21b662
commit
2839c87890
|
@ -1,6 +1,6 @@
|
||||||
# <a name="main"></a>C++ Core Guidelines
|
# <a name="main"></a>C++ Core Guidelines
|
||||||
|
|
||||||
August 11, 2017
|
September 17, 2017
|
||||||
|
|
||||||
|
|
||||||
Editors:
|
Editors:
|
||||||
|
@ -9103,6 +9103,8 @@ Consider:
|
||||||
X* p1 { new X }; // see also ???
|
X* p1 { new X }; // see also ???
|
||||||
unique_ptr<T> p2 { new X }; // unique ownership; see also ???
|
unique_ptr<T> p2 { new X }; // unique ownership; see also ???
|
||||||
shared_ptr<T> p3 { new X }; // shared ownership; see also ???
|
shared_ptr<T> p3 { new X }; // shared ownership; see also ???
|
||||||
|
auto p4 = make_unique<X>(); // unique_ownership, preferable to the explicit use "new"
|
||||||
|
auto p5 = make_shared<X>(); // shared ownership, preferable to the explicit use "new"
|
||||||
}
|
}
|
||||||
|
|
||||||
This will leak the object used to initialize `p1` (only).
|
This will leak the object used to initialize `p1` (only).
|
||||||
|
|
Loading…
Reference in New Issue
Block a user