Skip to content

Commit

Permalink
fix typo (#186)
Browse files Browse the repository at this point in the history
Signed-off-by: Zard-C <[email protected]>
  • Loading branch information
Zard-C authored Jul 5, 2024
1 parent 924b8aa commit 0ecc9cd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/5.RRefMovSemPerfForw/item29.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
考虑一下`std::array`,这是C++11中的新容器。`std::array`本质上是具有STL接口的内置数组。这与其他标准容器将内容存储在堆内存不同。存储具体数据在堆内存的容器,本身只保存了指向堆内存中容器内容的指针(真正实现当然更复杂一些,但是基本逻辑就是这样)。这个指针的存在使得在常数时间移动整个容器成为可能,只需要从源容器拷贝保存指向容器内容的指针到目标容器,然后将源指针置为空指针就可以了:

```cpp
std::vector<Widget> vm1;
std::vector<Widget> vw1;

//把数据存进vw1

//把vw1移动到vw2。以常数时间运行。只有vw1和vw2中的指针被改变
auto vm2 = std::move(vm1);
auto vw2 = std::move(vw1);
```

![item29_fig1](media/item29_fig1.png)
Expand Down

0 comments on commit 0ecc9cd

Please sign in to comment.