64 位环境中的引用大小 [英] Size of references in 64bit environments
问题描述
在浏览关于 SO 的另一个问题的回复时遇到了这个问题(引用 Vs 变量获取).我的问题是,对于所有 64 位环境,是否保证对变量的引用是 64 位,即使原始大小较小?就像在 64 位环境中的 char 引用一样,>sizeof(char)?标准中是否有任何部分明确规定了这一点?
Came across this one while browsing the response to another question on SO (References Vs Variable Gets). My question is that for all 64bit environments is it guaranteed that a reference to a variable will be of 64 bits even if the original had a lesser size? As in char references in 64bit environment would be >sizeof(char)? Is there any section in the standard which specifies this explicitly?
为了更清楚——字符 c1 = 'a';字符&c2 = c1;我的问题是 64 位机器中的 sizeof(c2) > sizeof(c1)?
For more clarity -- char c1 = 'a'; char& c2 = c1; My question is sizeof(c2) > sizeof(c1) in 64bit machines?
推荐答案
The Standard (ISO C++-03) 说到以下关于引用的事情
The Standard (ISO C++-03) says the following thing about references
未指定引用是否需要存储(3.7).
如果我错了或者我没有正确理解他的问题,请有人纠正我.
Please someone correct me if I am wrong or if I have not understood his question correctly.
编辑:
我的问题是 64 位机器中的 sizeof(c2) > sizeof(c1)?
My question is sizeof(c2) > sizeof(c1) in 64bit machines?
不,因为 @Chubsdad 注意到 sizeof(c2) = sizeof (c1)
,该标准的相关引用是
No, as @Chubsdad noticed sizeof(c2) = sizeof (c1)
, the relevant quote from the Standard is
应用于引用或引用类型时,结果是引用类型的大小
.(ISO C++ $5.3.3/2)
When applied to a reference or a reference type, the result is the size of the referenced type
. (ISO C++ $5.3.3/2)
这篇关于64 位环境中的引用大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!