如果最后一个地址为0xFFFFFFFF,如何获取一个数组末尾的地址? [英] How do I take the address of one past the end of an array if the last address is 0xFFFFFFFF?

查看:156
本文介绍了如果最后一个地址为0xFFFFFFFF,如何获取一个数组末尾的地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果合法的是将地址取一个数组的末尾,如果数组地址的最后一个元素 0xFFFFFFFF

If it is legal to take the address one past the end of an array, how would I do this if the last element of array's address is 0xFFFFFFFF?

此代码的工作原理:

for (vector<char>::iterator it = vector_.begin(), it != vector_.end(); ++it)
{
}

编辑:

我在这里读到在这个问题之前是合法的:我可以把一个过去的地址-end元素?

I read here that it is legal before making this question: May I take the address of the one-past-the-end element of an array?

推荐答案

如果这种情况对于特定架构是一个问题可能不是),那么编译器和运行时可以安排分配的数组从不结束 0xFFFFFFFF 。如果他们没有这样做,并且当数组 结束时,某些内容会断开,那么它们将不符合C ++标准。

If this situation is a problem for a particular architecture (it may or may not be), then the compiler and runtime can be expected to arrange that allocated arrays never end at 0xFFFFFFFF. If they were to fail to do this, and something breaks when an array does end there, then they would not conform to the C++ standard.

这篇关于如果最后一个地址为0xFFFFFFFF,如何获取一个数组末尾的地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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