mirror of
https://github.com/NixOS/nix
synced 2025-07-04 15:31:47 +02:00
refactor(treewide): make some move ctors noexcept where appropriate
This is good practice to avoid pessimisations. Left comments for the reasoning why ctors should be noexcept. There are some tricky cases where we intentionally want throwing move ctors/assignments. But those cases should really be reviewed, since some of those can be replaced with more idiomatic copy/move-and-swap.
This commit is contained in:
parent
492c678162
commit
96eeb6f4ff
8 changed files with 27 additions and 9 deletions
|
@ -45,8 +45,9 @@ AutoCloseFD::AutoCloseFD() : fd{INVALID_DESCRIPTOR} {}
|
|||
|
||||
AutoCloseFD::AutoCloseFD(Descriptor fd) : fd{fd} {}
|
||||
|
||||
|
||||
AutoCloseFD::AutoCloseFD(AutoCloseFD && that) : fd{that.fd}
|
||||
// NOTE: This can be noexcept since we are just copying a value and resetting
|
||||
// the file descriptor in the rhs.
|
||||
AutoCloseFD::AutoCloseFD(AutoCloseFD && that) noexcept : fd{that.fd}
|
||||
{
|
||||
that.fd = INVALID_DESCRIPTOR;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue