Weird XOR swap behavior while zeroing out data

前端 未结 3 1992
感情败类
感情败类 2021-01-21 07:31

Thanks Doug. Here\'s the fix:

void swap(int& a, int& b) {
    if (&a == &b) // added this check to ensure the same address is not passed in
              


        
3条回答
提交回复
热议问题