30 Input/output library [input.output]

30.10 File systems [filesystems]

30.10.34 Filesystem operation functions [fs.op.funcs]

30.10.34.19 Is empty [fs.op.is_empty]

bool is_empty(const path& p); bool is_empty(const path& p, error_code& ec) noexcept;

Effects:

  • Determine file_­status s, as if by status(p) or status(p, ec), respectively.

  • For the signature with argument ec, return false if an error occurred.

  • Otherwise, if is_­directory(s):

    • Create a variable itr, as if by directory_­iterator itr(p) or directory_­iterator itr(p, ec), respectively.

    • For the signature with argument ec, return false if an error occurred.

    • Otherwise, return itr == directory_­iterator().

  • Otherwise:

    • Determine uintmax_­t sz, as if by file_­size(p) or file_­size(p, ec), respectively.

    • For the signature with argument ec, return false if an error occurred.

    • Otherwise, return sz == 0.

Throws: As specified in [fs.err.report].