https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86015
--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> --- Every version of the standard says the same thing under iterator requirements: "For every iterator type X for which equality is defined, there is a corresponding signed integer type called the difference type of the iterator." Your distance objects are class types, which are not signed integer types.