[ 2018-04-10, Jonathan comments ]
There are more inconsistencies with paths that are "obviously" equivalent to the human reader:
path("a/b/c").lexically_relative("a/b/c") // yields "." path("a/b/c").lexically_relative("a/b/c/") // yields ".." path("a/b/c").lexically_relative("a/b/c/.") // yields "" path("a/b/c/").lexically_relative("a/b/c") // yields "" path("a/b/c/.").lexically_relative("a/b/c") // yields "." path("a/b/c/.").lexically_relative("a/b/c/") // yields "../."
I think the right solution is:
when counting [b, base.end()) in bullet (4.2) handle empty filename elements (which can only occur as the last element, due to a trailing slash) equivalently to dot elements; and
add a new condition for the case where n == 0 and [a, end()) contains no non-empty elements, i.e. the paths are equivalent except for final dots or a final slash, which don't introduce any relative difference between the paths.