27 Input/output library [input.output]

27.10 File systems [filesystems]

27.10.15 Filesystem operation functions [fs.op.funcs]

27.10.15.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].