This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] libstdc++/71005 fix post-increment for filesystem iterators


Eric pointed out that the post-increment operator on filesystem
directory iterators was returning the incremented value, because the
returnedobject shared its state with the incremented iterator.

This makes post-increment return a proxy, which contains the
directory_entry value before the increment.

	PR libstdc++/71005
	* include/experimental/bits/fs_dir.h (__directory_iterator_proxy):
	New type.
	(directory_iterator::operator++(int)): Return proxy.
	(recursive_directory_iterator::operator++(int)): Likewise.
	* testsuite/experimental/filesystem/iterators/directory_iterator.cc:
	Test post-increment.
	* testsuite/experimental/filesystem/iterators/
	recursive_directory_iterator.cc: Likewise.

Tested x86_64-linux, committed to trunk. Backports to follow.

Attachment: patch.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]