https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106014
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> --- We already have a custom std::distance for filesystem::path::iterator, and std::ranges::distance doesn't use that either. Maybe we want to add a customization point for std::ranges::distance that we can use internally. We also already have a custom std::advance for filesystem::path::iterator, because we can advance by N steps in O(1) instead of O(N). That might be possible for directory iterators too, so that advancing a directory iterator by N would only create a path for the final increment, not the intermediate ones. It wouldn't be O(1) but it would be a much cheaper O(N) than it is now.