I wrote a console program with VC : I found that once the sort value is all the same, and the total amount is greater than sort_max, and I have a custom function object: True returns True when it is determined to be equal (==). It will result in sorting abnormal (pointer, dead cycle):
Abnormal is the pointer, why can it lead to a cross-world, see below
#include "stdafx.h" #include
Class Greater {public: greater () {} Bool Operator () (int x1, int x2) {assert (x1 == 12); // I have made it here that the purpose is to judge the array crosions, why can it lead to a cross-boundary, See below if (x1> x2) Return False;}};
INT Main (int Argc, char * argv []) {// uint arr [] = {12, 14, 31, 9, 6, 30, 11, 65, 30 //}; uint arr [] = {12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12}; int nsize = sizeof (arr) / sizeof (uint); Greater GT Sort (Arr, Arr nsize, gt); for (int i = 0; i Return 0;} //// Sort is running here, there is a dead cycle in For (; _ p (* _ f, _piv); _ f), the reason is that the conditions I have started have all been satisfied (mainly _p (mainly _p) * _F, _piv) always return true), will lead to pointer offline, in addition, why always die cycle status, I am further studying ... Template