gpt4 book ai didi

c++ - std::unique_ptr 内存和性能

转载 作者:行者123 更新时间:2023-11-28 00:12:13 25 4
gpt4 key购买 nike

<分区>

When you reach for a smart pointer, std::unique_ptr should generally be the one closest at hand. It’s reasonable to assume that, by default, std::unique_ptrs are the same size as raw pointers, and for most operations (including dereferencing), they execute exactly the same instructions. This means you can use them even in situations where memory and cycles are tight. If a raw pointer is small enough and fast enough for you, a std::unique_ptr almost certainly is, too.

-Scott Meyers(高效现代 C++)

加粗的部分怎么可能是真的呢,在smart ptr中找到raw ptr然后调用方法需要两个阶段。他们怎么能一样快?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com