[PATCH] Overload std::distance and std::advance for path::iterator
Jonathan Wakely
jwakely@redhat.com
Thu Dec 13 12:09:00 GMT 2018
On 12/12/18 16:14 +0000, Jonathan Wakely wrote:
>+void
>+test04()
>+{
>+ std::filesystem::path p = "/a/b/c/d/e/f/g";
>+ VERIFY( std::distance(p.begin(), p.end()) == 8);
>+ auto it = p.begin();
>+ std::advance(it, 1);
>+ VERIFY( std::distance(p.begin(), it) == 1 );
>+ VERIFY( it->native() == "a" );
>+ std::advance(it, 3);
>+ VERIFY( std::distance(p.begin(), it) == 4 );
>+ VERIFY( it->native() == "d" );
>+ std::advance(it, -2);
>+ VERIFY( std::distance(p.begin(), it) == 2 );
>+ VERIFY( it->native() == "b" );
This fails on Windows because native() returns a wide string.
Fixed like so, committed to trunk.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.txt
Type: text/x-patch
Size: 1091 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20181213/44d0c18d/attachment.bin>
More information about the Libstdc++
mailing list