mirror of
https://github.com/NixOS/nix
synced 2025-06-29 06:21:14 +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
|
@ -21,7 +21,9 @@ public:
|
|||
|
||||
Callback(std::function<void(std::future<T>)> fun) : fun(fun) { }
|
||||
|
||||
Callback(Callback && callback) : fun(std::move(callback.fun))
|
||||
// NOTE: std::function is noexcept move-constructible since C++20.
|
||||
Callback(Callback && callback) noexcept(std::is_nothrow_move_constructible_v<decltype(fun)>)
|
||||
: fun(std::move(callback.fun))
|
||||
{
|
||||
auto prev = callback.done.test_and_set();
|
||||
if (prev) done.test_and_set();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue