This page is a snapshot from the LWG issues list, see theLibrary Active Issues List for more information and the meaning ofC++20 status.
noexcept issues with filesystem operationsSection: 31.12.13.5[fs.op.copy.file], 31.12.13.7[fs.op.create.directories], 31.12.13.32[fs.op.remove.all]Status:C++20Submitter: Tim SongOpened: 2017-08-23Last modified: 2021-06-06
Priority:Not Prioritized
View all otherissues in [fs.op.copy.file].
View all issues withC++20 status.
Discussion:
create_directories may need to create temporarypaths, andremove_all may need to create temporarypaths and/ordirectory_iterators. These operations may require a potentially throwing memory allocation.
copy_file may wish to dynamically allocate the buffer used for copying when the underlying OSdoesn't supply a copy API directly. This can happen indirectly, e.g., by using<fstream> facilities toperform the copying without supplying a custom buffer. Unless LWG wishes to prohibit using a dynamically allocated bufferin this manner, thenoexcept should be removed.[2017-11 Albuquerque Wednesday night issues processing]
Moved to Ready
[2018-3-17 Adopted in Jacksonville]
Proposed resolution:
This wording is relative toN4687.
Edit 31.12.4[fs.filesystem.syn], header<filesystem> synopsis, as indicated:
namespace std::filesystem { […] bool copy_file(const path& from, const path& to); bool copy_file(const path& from, const path& to, error_code& ec)noexcept; bool copy_file(const path& from, const path& to, copy_options option); bool copy_file(const path& from, const path& to, copy_options option, error_code& ec)noexcept; […] bool create_directories(const path& p); bool create_directories(const path& p, error_code& ec)noexcept; […] uintmax_t remove_all(const path& p); uintmax_t remove_all(const path& p, error_code& ec)noexcept; […]}Edit [fs.op.copy_file] as indicated:
bool copy_file(const path& from, const path& to);bool copy_file(const path& from, const path& to, error_code& ec)noexcept;-1-Returns: […]
-2-Throws: […]bool copy_file(const path& from, const path& to, copy_options options);bool copy_file(const path& from, const path& to, copy_options options, error_code& ec)noexcept;-3-Requires: […]
-4-Effects: […]-5-Returns: […]-6-Throws: […]-7-Complexity: […]
Edit [fs.op.create_directories] as indicated:
bool create_directories(const path& p);bool create_directories(const path& p, error_code& ec)noexcept;-1-Effects: […]
-2-Postconditions: […]-3-Returns: […]-4-Throws: […]-5-Complexity: […]
Edit [fs.op.remove_all] as indicated:
uintmax_t remove_all(const path& p);uintmax_t remove_all(const path& p, error_code& ec)noexcept;-1-Effects: […]
-2-Postconditions: […]-3-Returns: […]-4-Throws: […]