私は、2つの隣接するタプルを探してstd :: vectorを歩く比較的単純なアルゴリズムを持っています。 X値の左と右のタプルが見つかると、その間で補間できます。どういうわけか、この作品:この間なぜ2のNULLポインタがfalseに評価されないのですか?
std::vector<LutTuple*>::iterator tuple_it;
LutTuple* left = NULL;
LutTuple* right = NULL;
bool found = 0;
// Only iterate as long as the points are not found
for(tuple_it = lut.begin(); (tuple_it != lut.end() && !found); tuple_it++) {
// If the tuple is less than r2 we found the first element
if((*tuple_it)->r < r) {
left = *tuple_it;
}
if ((*tuple_it)->r > r) {
right = *tuple_it;
}
if(left && right) {
found = 1;
}
}
:
std::vector<LutTuple*>::iterator tuple_it;
LutTuple* left = NULL;
LutTuple* right = NULL;
// Only iterate as long as the points are not found
for(tuple_it = lut.begin(); tuple_it != lut.end() && !left && !right; tuple_it++) {
// If the tuple is less than r2 we found the first element
if((*tuple_it)->r < r) {
left = *tuple_it;
}
if ((*tuple_it)->r > r) {
right = *tuple_it;
}
}
はしていません。何故ですか?私は、このような2つのNULL ptrsが否定されたときに一緒に真に評価されると期待します。
http://en.wikipedia.org/wiki/De_Morgan's_laws – HostileFork