简体   繁体   English

布尔表达式成语中的这个字符串文字是什么?

[英]What is this string-literal in boolean expression idiom?

A coworker of mine was looking through one of our inherited code bases and found the following line: 我的一位同事正在查看我们继承的代码库之一,并找到以下行:

ATLASSERT( rtaddress == m_lRTAddress && "Creation settings should match FIFO" );

We don't understand what the purpose of the string literal is for; 我们不明白字符串文字的目的是什么; is it for more than just commenting? 这不仅仅是评论吗? The way I see it, if rtaddress does NOT equal m_lRTAddress then the string will never be evaluated due to short circuiting. 我看到它的方式,如果rtaddress不等于m_lRTAddress那么由于短路,字符串永远不会被评估。 If rtaddress DOES equal m_lRTAddress then the string literal will be evaluated but a string literal evaluated for a boolean expression will always return true ; 如果rtaddress等于m_lRTAddress那么将对字符串文字进行求值,但对布尔表达式求值的字符串文字将始终返回true ; so what's the point? 那有什么意义呢?

我认为如果断言失败,你可以看到为什么添加断言的原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 符号\ 0在字符串文字中的含义是什么? - What does the symbol \0 mean in a string-literal? 通过char返回本地字符串字面量* - Returning local string-literal by char* 错误:“命令”之前预期的字符串字面意义/重新使用asm volatile - error: expected string-literal before ‘command’ / reusing asm volatile 功能范围内的“外部字符串文字声明” - “extern string-literal declaration” within function scope 是否有可能在 C++ 中强制执行字符串文字 function 参数? - Is it possible in C++ to enforce a string-literal function argument? constexpr 字符串文字检查:语法短,没有运行时可能性 - constexpr string-literal checking: short syntax, no runtime possibility C ++:将类型为const char *的字符串文字传递给字符串参数 - C++: passing a string-literal of Type const char* to a string-parameter 为什么这个模板签名不能用作引号的字符串文字? - Why doesn't this template signature work as a string-literal using quotes? 在 C++17 和 C++20 之间可移植地使用 UTF-8 字符串文字前缀 - Using UTF-8 string-literal prefixes portably between C++17 and C++20 分解复杂表达式的好的编码习惯是什么? - What is good coding idiom to decompose a complicated expression?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM