October 23
https://issues.dlang.org/show_bug.cgi?id=24827

          Issue ID: 24827
           Summary: maxElement does not correctly handle types with
                    opAssign
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody@puremagic.com
          Reporter: issues.dlang@jmdavisProg.com

Strictly speaking, I'm pretty sure that the problem here is that Rebindable2 doesn't use emplaceCopy but instead uses =, but maxElement is the public symbol which exposes this issue, an example being

---
void main()
{
    import std.algorithm.searching : maxElement;
    auto arr = [S(19), S(2), S(145), S(7)];
    assert(maxElement(arr) == S(145));
}

struct S
{
    int i;
    bool destroyed;

    this(int i)
    {
        this.i = i;
    }

    ~this()
    {
        destroyed = true;
    }

    bool opEquals()(auto ref S rhs)
    {
        return this.i == rhs.i;
    }

    int opCmp()(auto ref S rhs)
    {
        if(this.i < rhs.i)
            return -1;

        return this.i == rhs.i ? 0 : 1;
    }

    invariant
    {
        assert(!destroyed);
    }
}
---

This results is the assertion in the invariant failing a bunch of times.

--