c++ - Why does std::sort compare the element to itself -


As the subject says, why do some of the elements in the code below compare to them?

  # include & lt; Iostream & gt; #include & lt; Vector & gt; # Include & lt; Algorithm & gt; Class A {public: A (int value): Value (value) {} ~ A () {} Bool operator & lt; (Consta and RA) Const {if (>-> value == rhs.value) std :: cout & lt; & Lt; This & lt; & Lt; "" & Lt; & Lt; This- & gt; Value & lt; & Lt; "\ T" & lt; & Lt; & Amp; Amp; Rhs & lt; & Lt; "" & Lt; & Lt; Rhs.value & lt; & Lt; Std :: endl; If (this-> values> ls; rhs.value) return true; return false; } At Value; }; Int main (int argc, char * argv []) {std :: vector & lt; A & gt; Vec; For (int i = 0; i   

I tried the above code on Windows, Linux and OpenBSD, it seems to be on Windows that it does not compare the element in itself, but it would have happened on both Linux and OpenBSD is. My guess is that it is used because of various libraries.

On Linux, I get an output similar to this:

  0x96be0d0 8xxxx8x08x08x8 

If std :: sort is enforced as a quick type, in case, you can wash the current element Comparison with Elements I do not have my Sedgewick algorithm , but I think the avoidance of this comparison will not speed up the algorithm (or harm to the comparison algorithm complexity) Not). If you want you can see the exact quote.

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -