September 10, 2021
https://issues.dlang.org/show_bug.cgi?id=22297

          Issue ID: 22297
           Summary: Behavior of minElement and maxElement with empty range
                    is undocumented
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody@puremagic.com
          Reporter: snarwin+bugzilla@gmail.com

The documentation for minElement and maxElement does not specify what happens when either function is called with an empty range as its argument.

Experimentation reveals that what happens is an assertion failure, which terminates the program:

---
import std.algorithm.searching;
void main()
{
    int[] emptyArr;
    auto min = minElement(emptyArr); // AssertError: r is an empty range
}
---

This behavior should be documented.

--