Share all recursive_directory_iterator state [LWG 2708]
authorJonathan Wakely <jwakely@redhat.com>
Fri, 5 Apr 2019 16:56:23 +0000 (17:56 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Fri, 5 Apr 2019 16:56:23 +0000 (17:56 +0100)
commitc7dde4a90afd3d83cfaae2e278dd8686bca1dc3d
treed95708b122ff1d049743f3ab7de6a6973a0654e9
parent5ed5c0da8ba2491d765ecb260e1babaa83a38b12
Share all recursive_directory_iterator state [LWG 2708]

Implement the proposed resolution of LWG 2708 by moving the _M_options
and _M_pending members out of the recursive_directory_iterator into the
shared _Dir_stack object. Because _Dir_stack is an opaque type, the
member functions that access the _M_options and _M_pending variables
cannot be inline. Move them into the library.

As a drive-by fix, add noexcept to the non-throwing member functions of
recursive_directory_iterator.

* config/abi/pre/gnu.ver: Export new symbols.
* include/bits/fs_dir.h (recursive_directory_iterator::options())
(recursive_directory_iterator::recursion_pending())
(recursive_directory_iterator::disable_recursion_pending()): Remove
inline definitions. Make noexcept.
(recursive_directory_iterator::depth())
(recursive_directory_iterator::operator*())
(recursive_directory_iterator::operator->()): Make noexcept.
(recursive_directory_iterator::_M_options)
(recursive_directory_iterator::_M_pending): Remove data members.
* src/c++17/fs_path.cc (_Dir_stack): Add constructor and data members.
(recursive_directory_iterator::recursive_directory_iterator): Remove
ctor-initializer. Use new constructor for _Dir_stack.
(recursive_directory_iterator::options())
(recursive_directory_iterator::recursion_pending())
(recursive_directory_iterator::disable_recursion_pending()): Add
non-inline definitions.
(recursive_directory_iterator::depth()): Make noexcept.
(recursive_directory_iterator::increment(error_code&))
(recursive_directory_iterator::pop(error_code&)): Adjust to new
location of options and recursion_pending members.
* testsuite/27_io/filesystem/iterators/recursion_pending.cc: New test.
* testsuite/util/testsuite_fs.h (__gnu_test::scoped_file): Add
user-declared move constructor and assignment operator, to make the
type move-only.

From-SVN: r270173
libstdc++-v3/ChangeLog
libstdc++-v3/config/abi/pre/gnu.ver
libstdc++-v3/include/bits/fs_dir.h
libstdc++-v3/src/c++17/fs_dir.cc
libstdc++-v3/testsuite/27_io/filesystem/iterators/recursion_pending.cc [new file with mode: 0644]
libstdc++-v3/testsuite/util/testsuite_fs.h