久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

比較指向不同數組的指針是否相等是未指定的行

Is it unspecified behavior to compare pointers to different arrays for equality?(比較指向不同數組的指針是否相等是未指定的行為嗎?)
本文介紹了比較指向不同數組的指針是否相等是未指定的行為嗎?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

相等運算符在指針上具有關系運算符的語義限制:

The equality operators have the semantic restrictions of relational operators on pointers:

==(等于)和 !=(不等于)運算符與關系運算符具有相同的語義限制、轉換和結果類型,但它們的優先級和真值結果較低.[C++03 §5.10p2]

The == (equal to) and the != (not equal to) operators have the same semantic restrictions, conversions, and result type as the relational operators except for their lower precedence and truth-value result. [C++03 §5.10p2]

關系運算符對比較指針有限制:

And the relational operators have a restriction on comparing pointers:

如果兩個相同類型的指針 p 和 q 指向不同的對象,這些對象不是同一對象的成員或同一數組的元素或不同的函數,或者只有其中一個為空,則 p<q、p>q、p<=q和p>=q是未指定的.[§5.9p2]

If two pointers p and q of the same type point to different objects that are not members of the same object or elements of the same array or to different functions, or if only one of them is null, the results of p<q, p>q, p<=q, and p>=q are unspecified. [§5.9p2]

這是由等式運算符繼承"的語義限制嗎?

Is this a semantic restriction which is "inherited" by equality operators?

具體來說,給定:

int a[42];
int b[42];

很明顯 (a + 3) <(b + 3) 是未指定的,但是 (a + 3) == (b + 3) 也是未指定的嗎?

It is clear that (a + 3) < (b + 3) is unspecified, but is (a + 3) == (b + 3) also unspecified?

推薦答案

op==op!= 的語義明確表示映射是 除了他們的真值結果.因此,您需要查看為它們的真值結果定義了什么.如果他們說結果未指定,那么它就是未指定的.如果他們定義了特定的規則,那就不是.它特別說

The semantics for op== and op!= explicitly say that the mapping is except for their truth-value result. So you need to look what is defined for their truth value result. If they say that the result is unspecified, then it is unspecified. If they define specific rules, then it is not. It says in particular

相同類型的兩個指針比較相等當且僅當它們都為空,都指向同一個函數,或者都代表同一個地址

Two pointers of the same type compare equal if and only if they are both null, both point to the same function, or both represent the same address

這篇關于比較指向不同數組的指針是否相等是未指定的行為嗎?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Difference between std::reference_wrapper and simple pointer?(std::reference_wrapper 和簡單指針的區別?)
Difference between const. pointer and reference?(常量之間的區別.指針和引用?)
How to access the contents of a vector from a pointer to the vector in C++?(c++ - 如何從指向向量的指針訪問向量的內容?)
Meaning of *amp; and **amp; in C++(*amp; 的含義和**amp;在 C++ 中)
Why can#39;t I do polymorphism with normal variables?(為什么我不能對普通變量進行多態?)
Dereferencing deleted pointers always result in an Access Violation?(取消引用已刪除的指針總是會導致訪問沖突?)
主站蜘蛛池模板: 国产一区二区三区久久 | 国产精品五区 | 玖玖色资源 | av在线免费网站 | 成人激情视频 | 日韩欧美精品一区二区 | 一级黄色免费视频 | 中文字幕免费在线看线人动作大片 | 精品日韩av | 亚洲丝袜av | av免费网 | 欧美综合网 | 国产日韩在线播放 | 黑人操亚洲女人 | 九九热这里有精品 | 3d动漫精品h区xxxxx区 | 自拍视频一区 | 欧美在线激情 | 国产免费无遮挡 | 国产麻豆xxxvideo实拍 | 成人做爰免费视频免费看 | 欧美综合视频 | 国产福利视频在线观看 | 天天干天天操天天干 | 亚洲最新视频 | 国产激情在线视频 | 美日韩精品 | www.chengren | 黄色一级片免费 | 在线看亚洲| 在线色网站 | 亚洲天堂免费视频 | 日韩精品在线观看视频 | 成人在线免费视频观看 | 国产成人精品亚洲男人的天堂 | 特级丰满少妇一级aaaa爱毛片 | 伊人天堂网 | 毛片久久 | 午夜精品久久久久久久 | 亚洲激情综合网 | 欧美日韩国产中文 |