Warum stürzt std :: sort ab, wenn die Vergleichsfunktion nicht als Operator <ausgeführt wird?

Das folgende Programm ist mit VC ++ 2012 kompiliert.

#include <algorithm>

struct A
{
    A()
        : a()
    {}

    bool operator <(const A& other) const
    {
        return a <= other.a;
    }

    int a;
};

int main()
{
    A coll[8];
    std::sort(&coll[0], &coll[8]); // Crash!!!
}

Wenn ich mich änderereturn a <= other.a; zureturn a < other.a; dann läuft das programm wie erwartet ohne ausnahme.

Warum?

Antworten auf die Frage(2)

Ihre Antwort auf die Frage