在64位环境中引用的大小 [英] Size of references in 64bit environments

查看:158
本文介绍了在64位环境中引用的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

过这个人来同时浏览上,这样回答另一个问题时(<一href="http://stackoverflow.com/questions/3744635/c-is-it-a-good-idea-to-always-return-references-for-member-variable-getters">References VS Variable获取)。 我的问题是,对于所有的64位环境中能够保证所有的引用变量将是64位的,即使原来有一个较小的规模?如在64位环境中字符引用会>的sizeof(字符)?是否有一个明确指定该标准中的任何部分?

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; 我的问题是的sizeof(C2)>的sizeof(C1)的64位机?

For more clarity -- char c1 = 'a'; char& c2 = c1; My question is sizeof(c2) > sizeof(c1) in 64bit machines?

推荐答案

标准(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.

修改

我的问题是的sizeof(C2)>的sizeof(C1)的64位机?

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆