Skip to content

Commit

Permalink
Update item21.md (#187)
Browse files Browse the repository at this point in the history
  • Loading branch information
laiqun authored Jul 10, 2024
1 parent 0ecc9cd commit 199be3f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/4.SmartPointers/item21.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ auto spw = std::make_shared<Widget>();

更倾向于使用`make`函数而不是直接使用`new`的争论非常激烈。尽管它们在软件工程、异常安全和效率方面具有优势,但本条款的建议是,更**倾向于**使用`make`函数,而不是完全依赖于它们。这是因为有些情况下它们不能或不应该被使用。

例如,`make`函数都不允许指定自定义删除器(见[Item18](../4.SmartPointers/item18.md)[19](../4.SmartPointers/item19.md)),但是`std::unique_ptr``std::shared_ptr`有构造函数这么做。有个`Widget`的自定义删除器:
例如,`make`函数都不允许指定自定义删除器(见[Item18](../4.SmartPointers/item18.md)[19](../4.SmartPointers/item19.md)),但是`std::unique_ptr``std::shared_ptr`的构造函数可以接收一个删除器参数。有个`Widget`的自定义删除器:
```cpp
auto widgetDeleter = [](Widget* pw) { … };
```
Expand Down

0 comments on commit 199be3f

Please sign in to comment.