Merge pull request #66 from bz521/patch-2

Update item18.md
This commit is contained in:
Yang Yi 2021-01-18 19:09:19 +08:00 committed by GitHub
commit deb428addf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -31,14 +31,14 @@
```cpp
class Investment { ... };
class Sock: public Investment {...};
class Stock: public Investment {...};
class Bond: public Investment {...};
class RealEstate: public Investment {...};
```
```mermaid
classDiagram
Investment <|-- Sock
Investment <|-- Stock
Investment <|-- Bond
Investment <|-- RealEstate
```
@ -121,7 +121,7 @@ makeInvestment(Ts&& params)
```cpp
template<typename... Ts>
makeInvestment(Ts&& params)
auto makeInvestment(Ts&& params)
{
auto delInvmt = [](Investment* pInvestment)
{
@ -187,4 +187,4 @@ std::shared_ptr<Investment> sp = makeInvestment(arguments);
- `std::unique_ptr`是轻量级、快速的、只能move的管理专有所有权语义资源的智能指针
- 默认情况资源销毁通过delete但是支持自定义delete函数。有状态的删除器和函数指针会增加`std::unique_ptr`的大小
- 将`std::unique_ptr`转化为`std::shared_ptr`是简单的
- 将`std::unique_ptr`转化为`std::shared_ptr`是简单的