Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Fix error #144
Merged
Fix error #144
Conversation
@@ -175,7 +175,7 @@ int main() { | |||
|
|||
在上图中,最后一步只剩下 B,而 B 并没有任何智能指针引用它,因此这块内存资源也会被释放。 | |||
|
|||
`std::weak_ptr` 没有 `*` 运算符和 `->` 运算符,所以不能够对资源进行操作,它的唯一作用就是用于检查 `std::shared_ptr` 是否存在,其 `expired()` 方法能在资源未被释放时,会返回 `true`,否则返回 `false`。 | |||
`std::weak_ptr` 没有 `*` 运算符和 `->` 运算符,所以不能够对资源进行操作,它的唯一作用就是用于检查 `std::shared_ptr` 是否存在,其 `expired()` 方法能在资源未被释放时,会返回 `false`,否则返回 `true`。 |
changkun
Nov 17, 2020
Owner
Could you please maybe also fix the error in book/en-us/05-pointers.md
?
Could you please maybe also fix the error in book/en-us/05-pointers.md
?
spartucus
Nov 17, 2020
Author
Contributor
Sure thing!
Sure thing!
spartucus
Nov 17, 2020
Author
Contributor
Done!
Done!
Fix error, while the resource of `std::shared_ptr` exists, `std::weak_ptr`'s `expired()` method returns `false`, otherwise it returns `true`.
Thank you so much for your contribution! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Description
Fix error, while the resource of
std::shared_ptr
exists, theexpired()
method ofstd::weak_ptr
returnsfalse
, otherwise returnstrue
.Change List
expired()
return valueReference
https://en.cppreference.com/w/cpp/memory/weak_ptr/expired
说明
修复错误,
std::shared_ptr
资源尚存在时,std::weak_ptr
的expired()
方法返回false
, 否则返回true
。变化箱单
std::weak_ptr
的expired()
方法返回值错误参考文献
https://en.cppreference.com/w/cpp/memory/weak_ptr/expired