std::sort crashed when using own iterator
Try to write an algorithm to perform sort for matrix’s diagonal. And I thought to right an iterator which can visit diagonals and then leverage std::sort to perform sort, the problem is, in some test cases, the std::sort throw exception, and after adding log, seems the index is negative after perform operator– and this caused invalid memory visit. I have tried best to understand where is the problem, however no luck, hope can get some brilliant help:)