Section: 31.12.13.20 [fs.op.is.empty] Status: C++17 Submitter: Jonathan Wakely Opened: 2014-08-01 Last modified: 2021-06-06
Priority: 3
View all issues with C++17 status.
Discussion:
The descriptions of most functions are explicit about the use of the ec
argument,
either saying something like "foo(p)
or foo(p, ec)
, respectively" or using the
ec
argument like foo(p[, ec])
, but is_empty
does not.
[fs.op.is_empty]/2 refers to ec
unconditionally, but more importantly
[fs.op.is_empty]/3 doesn't pass ec
to the directory_iterator
constructor or the file_size
function.
[ 9 Oct 2014 Beman supplies proposed wording. ]
[Apr 2016 Issue updated to address the C++ Working Paper. Previously addressed File System TS]
Previous resolution [SUPERSEDED]:
bool is_empty(const path& p); bool is_empty(const path& p, error_code& ec) noexcept;Effects:
- Determine
file_status s
, as if bystatus(p)
orstatus(p, ec)
, respectively.- For the signature with argument
ec
, returnfalse
if an error occurred.- Otherwise, if
is_directory(s)
:
- Create
directory_iterator itr
, as if bydirectory_iterator(p)
ordirectory_iterator(p, ec)
, respectively.- For the signature with argument
ec
, returnfalse
if an error occurred.- Otherwise, return
itr == directory_iterator()
.- Otherwise:
- Determine
uintmax_t sz
, as if byfile_size(p)
orfile_size(p, ec)
, respectively .- For the signature with argument
ec
, returnfalse
if an error occurred.- Otherwise, return
sz == 0
.Remarks: The temporary objects described in Effects are for exposition only. Implementations are not required to create them.
Returns:
See Effects.is_directory(s) ? directory_iterator(p) == directory_iterator() : file_size(p) == 0;
The signature with argumentec
returnsfalse
if an error occurs.Throws: As specified in Error reporting (7).
[2016-08 Chicago]
Wed PM: Move to Tentatively Ready
Proposed resolution:
bool is_empty(const path& p); bool is_empty(const path& p, error_code& ec) noexcept;Effects:
- Determine
file_status s
, as if bystatus(p)
orstatus(p, ec)
, respectively.- For the signature with argument
ec
, returnfalse
if an error occurred.- Otherwise, if
is_directory(s)
:
- Create
directory_iterator itr
, as if bydirectory_iterator(p)
ordirectory_iterator(p, ec)
, respectively.- For the signature with argument
ec
, returnfalse
if an error occurred.- Otherwise, return
itr == directory_iterator()
.- Otherwise:
- Determine
uintmax_t sz
, as if byfile_size(p)
orfile_size(p, ec)
, respectively .- For the signature with argument
ec
, returnfalse
if an error occurred.- Otherwise, return
sz == 0
.
Returns:is_directory(s) ? directory_iterator(p) == directory_iterator() : file_size(p) == 0;
The signature with argumentec
returnsfalse
if an error occurs.Throws: As specified in Error reporting (7).