mirror of
https://github.com/NixOS/nix.git
synced 2025-11-11 21:16:02 +01: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
|
|
@ -42,7 +42,8 @@ struct SQLite
|
|||
SQLite(const Path & path, SQLiteOpenMode mode = SQLiteOpenMode::Normal);
|
||||
SQLite(const SQLite & from) = delete;
|
||||
SQLite& operator = (const SQLite & from) = delete;
|
||||
SQLite& operator = (SQLite && from) { db = from.db; from.db = 0; return *this; }
|
||||
// NOTE: This is noexcept since we are only copying and assigning raw pointers.
|
||||
SQLite& operator = (SQLite && from) noexcept { db = from.db; from.db = 0; return *this; }
|
||||
~SQLite();
|
||||
operator sqlite3 * () { return db; }
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue