久久久久久久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?(取消引用已刪除的指針總是會導致訪問沖突?)
主站蜘蛛池模板: 天堂一区二区三区四区 | 日本超碰 | 91在线观看 | 四虎影视免费在线 | 欧美综合国产精品久久丁香 | 永久精品| 亚洲第一天堂无码专区 | 国产成人精品综合 | 免费在线黄 | 中文字幕在线免费观看 | 亚洲精品久久久久久久久久久久久 | 亚洲免费人成在线视频观看 | 中文字幕人成乱码在线观看 | 日韩在线一区二区 | 国产日韩欧美激情 | 国产精品资源在线 | 成人国产精品一级毛片视频毛片 | 国产一区二区 | 网站一区二区三区 | 日韩二区三区 | 欧美性生交大片免费 | 久久国产精品99久久久大便 | 亚洲逼院 | 国产91网址| 欧美精品在线一区二区三区 | 精品成人在线 | 久久性色 | 黄色片在线网站 | 国产在线视频一区 | 成人在线免费 | 婷婷丁香在线视频 | 日韩中文字幕在线 | 91视频电影| 色视频在线免费观看 | 丝袜美腿av| 精品在线一区 | 91视视频在线观看入口直接观看 | 国产精品视频在线观看 | 日韩不卡在线 | 一区二区三区观看视频 | 日韩欧美国产精品 |