Title
directory_entry, directory_iterator and recursive_directory_iterator perform needless path copies
Status
new
Section
[fs.class.directory.entry][fs.class.directory.iterator] [fs.class.rec.dir.itr]
Submitter
Gor Nishanov

Created on 2018-03-05.00:00:00 last changed 81 months ago

Messages

Date: 2018-03-20.00:00:00

[ 2018-03-20 Priority set to 3 after discussion on the reflector. ]

Date: 2018-03-05.00:00:00

An implementation of directory_entry class is likely to store a filesystem::path as a member. Constructors and assign member functions take filesystem::path by const& thus forcing creation of a copy.

An implementation of directory_iterator class is likely to store a directory_entry or a path as a part of its state. Constructors take filesystem::path by const& thus forcing creation of a copy.

An implementation of recursive_directory_iterator class is likely to store a directory_entry or a path as a part of its state. Constructors take filesystem::path by const& thus forcing creation of a copy.

Suggested resolution:

Add overloads to directory_entry, directory_iterator, and recursive_directory_iterator that take filesystem::path by &&.

Make it unspecified in case an exception is thrown from those new members where an argument was moved from or not.

explicit directory_entry(const filesystem::path& p);
explicit directory_entry(filesystem::path&& p);
directory_entry(const filesystem::path& p, error_code& ec);
directory_entry(filesystem::path&& p, error_code& ec);

void directory_entry::assign(const filesystem::path& p);
void directory_entry::assign(filesystem::path&& p);
void directory_entry::assign(const filesystem::path& p, error_code& ec);
void directory_entry::assign(filesystem::path&& p, error_code& ec);

explicit directory_iterator(const path& p);
explicit directory_iterator(path&& p);
directory_iterator(const path& p, directory_options options);
directory_iterator(path&& p, directory_options options);
directory_iterator(const path& p, error_code& ec) noexcept;
directory_iterator(path&& p, error_code& ec) noexcept;
directory_iterator(const path& p, directory_options options, error_code& ec) noexcept;
directory_iterator(path&& p, directory_options options, error_code& ec) noexcept;

explicit recursive_directory_iterator(const path& p);
explicit recursive_directory_iterator(path&& p);
recursive_directory_iterator(const path& p, directory_options options);
recursive_directory_iterator(path&& p, directory_options options);
recursive_directory_iterator(const path& p, directory_options options, error_code& ec) noexcept;
recursive_directory_iterator(path&& p, directory_options options, error_code& ec) noexcept;
recursive_directory_iterator(const path& p, error_code& ec) noexcept;
recursive_directory_iterator(path&& p, error_code& ec) noexcept;
History
Date User Action Args
2018-03-25 13:22:33adminsetmessages: + msg9784
2018-03-05 00:00:00admincreate