Overload std::distance and std::advance for path::iterator
authorJonathan Wakely <jwakely@redhat.com>
Wed, 12 Dec 2018 16:13:49 +0000 (16:13 +0000)
committerJonathan Wakely <redi@gcc.gnu.org>
Wed, 12 Dec 2018 16:13:49 +0000 (16:13 +0000)
commit9e160526440decfabecbe06e7ed22ee828d93010
tree81f49981f5999dc6c0ecbbb872db30467b46e1d5
parent6b7c0b5559316028d392d2bf9a4a0ca9e7562ce7
Overload std::distance and std::advance for path::iterator

Although filesystem::path::iterator is only a bidirectional iterator,
the underlying sequence has random access iterators (specifically, raw
pointers). This means std::distance and std::advance can be implemented
more efficiently than the generic versions which apply ++ and --
repeatedly.

PR libstdc++/71044 (partial)
* include/bits/fs_path.h (__path_iter_distance, __path_iter_advance):
New friend functions to implement std::distance and std::advance more
efficiently.
(distance, advance): Add overloads for path::iterator.
* testsuite/27_io/filesystem/path/itr/components.cc: Test new
overload.

From-SVN: r267057
libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/fs_path.h
libstdc++-v3/testsuite/27_io/filesystem/path/itr/traversal.cc