gpt4 book ai didi

c++ - boost enable_shared_from_this 功能是否会增加二进制文件的大小?

转载 作者:行者123 更新时间:2023-11-30 00:53:55 25 4
gpt4 key购买 nike

我不知道这个问题是否适合 SO,但我们开始了:

启用 shared_from_this 时,是否会增加可执行文件的大小?解决 shared_from_this() 调用是否也需要太多时间?

查看文档,enable_shared_from_this 是一个只添加了两个函数的助手,所以我认为它不应该占用太多额外的空间。

编辑 这个问题更合适的标题应该是,它增加了多少尺寸?而不是询问它是否增加了太多尺寸。

最佳答案

When enabling shared_from_this, does it adds too much size to the executable?

运行时,它会为每个实例化对象添加一个weak_ptr的大小,在当前版本的boost中,是2个指针的大小.

至于可执行二进制本身,很难预测更改源代码将如何影响该文件的大小。

Does it also take too much time to resolve the shared_from_this() call?

您应该预料到从 weak_ptr 构造一个 shared_ptr 所花费的时间。

关于c++ - boost enable_shared_from_this 功能是否会增加二进制文件的大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15248341/

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