29 Input/output library [input.output]

29.11 File systems [filesystems]

29.11.14 Filesystem operation functions [fs.op.funcs]

29.11.14.32 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
:
  • If old_­p and new_­p resolve to the same existing file, no action is taken.
  • Otherwise, the rename may 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 may 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].