27 Input/output library [input.output]

27.10 File systems [filesystems]

27.10.15 Filesystem operation functions [fs.op.funcs]

27.10.15.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 directory_iterator itr, as if by directory_iterator(p) or directory_iterator(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].