(这个问题的Is compound if checking for null and then other condition in C++ always safe?但关于C,不C++完全相同的副本。有人指出,问题应该是更具体的)。 我一直使用以下类型的if条件进行了大量的时间。 char* ptr = ...;
if (ptr != NULL && ptr[0] != '\0') // <==
在this的问题中留言的顺序: 不要依赖于短路......这些条款可以以任意顺序SQL Server中评估认为合适的。 由于涉及到这样的回答: SELECT * FROM TABLE WHERE (@vari is null or col = @vari)
这是正确的吗? 有没有一个好的测试设置,也许在SQL小提琴中,可以重现这种现象? (使用这个术语相当宽松) 这是否只发生在WHERE子句?
这个陈述的等价物是什么? if(cond1 AND cond2 AND cond3 OR cond4 AND cond5 AND cond6)
是否 if((cond1 AND cond2 AND cond3) OR (cond4 AND cond5 AND cond6))
或者 if(cond1 AND cond2 AND (cond3 OR cond4) AND cond5 AND c