gpt4 book ai didi

c++ - 引用类型和存储期限

转载 作者:行者123 更新时间:2023-11-30 04:03:07 25 4
gpt4 key购买 nike

首先,我引用存储期限的定义(sec. 3.7.1/1 N3797):

Storage duration is the property of an object that defines the minimum potential lifetime of the storage containing the object.

但是 3.7.1/3 说:

The storage duration categories apply to references as well.

很好奇。我认为引用在内存中根本没有表示。我还认为一个对象并且只有对象在内存中表示(第 1.8/1 节):

An object is a region of storage.

将存储持续时间概念引入引用有什么意义?

最佳答案

来自§8.3.2/4:

It is unspecified whether or not a reference requires storage.

因此,如果引用确实需要一些存储空间,则该存储空间的生命周期对应于引用的存储持续时间。

关于c++ - 引用类型和存储期限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24674609/

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