Accounting for correctness even in edge-cases is what large libraries do better than throwaway bits of code.
[1]: https://github.com/microsoft/STL/blob/6735beb0c2260e325c3a4c...