Modify rule S5950: Move exception code example and update links
This commit is contained in:
parent
e5b3e078f3
commit
b965af0518
@ -46,9 +46,6 @@ std::shared_ptr<MyClass> sharedP(new MyClass(42)); // Noncompliant
|
||||
----
|
||||
auto uniqueP = std::make_unique<MyClass>(42);
|
||||
auto sharedP = std::make_shared<MyClass>(42);
|
||||
std::unique_ptr<std::FILE, std::function<void(std::FILE*)>> file(
|
||||
fopen("example.txt", "r"),
|
||||
[](FILE* inFile) { fclose(inFile); }); // Compliant: custom deleter is specified
|
||||
----
|
||||
|
||||
|
||||
@ -57,6 +54,14 @@ std::unique_ptr<std::FILE, std::function<void(std::FILE*)>> file(
|
||||
This rule ignores code that uses features not supported by `make_shared` and `make_unique`:
|
||||
|
||||
* custom deleters
|
||||
|
||||
[source,cpp]
|
||||
----
|
||||
std::unique_ptr<std::FILE, std::function<void(std::FILE*)>> file(
|
||||
fopen("example.txt", "r"),
|
||||
[](FILE* inFile) { fclose(inFile); }); // Compliant: custom deleter is specified
|
||||
----
|
||||
|
||||
* calling placement-new, i.e., version of `new` with arguments, like `new(std::nothrow)`
|
||||
|
||||
In addition, `make_shared` does not support the following:
|
||||
@ -66,8 +71,8 @@ In addition, `make_shared` does not support the following:
|
||||
|
||||
== Resources
|
||||
|
||||
* https://github.com/isocpp/CppCoreGuidelines/blob/c553535fb8dda2839d13ab5f807ffbc66b63d67b/CppCoreGuidelines.md#c150-use-make_unique-to-construct-objects-owned-by-unique_ptrs[{cpp} Core Guidelines C.150] - Use make_unique() to construct objects owned by unique_ptrs
|
||||
* https://github.com/isocpp/CppCoreGuidelines/blob/c553535fb8dda2839d13ab5f807ffbc66b63d67b/CppCoreGuidelines.md#c151-use-make_shared-to-construct-objects-owned-by-shared_ptrs[{cpp} Core Guidelines C.151] - Use make_shared() to construct objects owned by shared_ptrs
|
||||
* {cpp] Core Guidelines - https://github.com/isocpp/CppCoreGuidelines/blob/036324/CppCoreGuidelines.md#c150-use-make_unique-to-construct-objects-owned-by-unique_ptrs[C.150 - Use make_unique() to construct objects owned by unique_ptrs]
|
||||
* {cpp] Core Guidelines - https://github.com/isocpp/CppCoreGuidelines/blob/036324/CppCoreGuidelines.md#c151-use-make_shared-to-construct-objects-owned-by-shared_ptrs[C.151 - Use make_shared() to construct objects owned by shared_ptrs]
|
||||
|
||||
ifdef::env-github,rspecator-view[]
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user