29 Input/output library [input.output]

29.11 File systems [filesystems]

29.11.13 Filesystem operation functions [fs.op.funcs]

29.11.13.33 Rename [fs.op.rename]

void rename(const path& old_p, const path& new_p); void rename(const path& old_p, const path& new_p, error_code& ec) noexcept;
Effects: Renames old_­p to new_­p, as if by POSIX rename().
[Note 1:
  • If old_­p and new_­p resolve to the same existing file, no action is taken.
  • Otherwise, the rename can include the following effects:
    • if new_­p resolves to an existing non-directory file, new_­p is removed; otherwise,
    • if new_­p resolves to an existing directory, new_­p is removed if empty on POSIX compliant operating systems but might be an error on other operating systems.
A symbolic link is itself renamed, rather than the file it resolves to.
— end note]
Throws: As specified in [fs.err.report].