flow: Add noexcept
to move ctors (at least); including to avoid copying in vector (at least).
#76
Labels
noexcept
to move ctors (at least); including to avoid copying in vector (at least).
#76
Filed by @ygoldfeld pre-open-source:
Probably all move ctors here – but also look at
ipc
– should benoexcept
. Also look atnoexcept
in general and see what prophylactic moves would be good. I am not super familiar with the topic.What triggered this:
I made a vector and noticed that when it needs to re-alloc, for example due to an emplace_back(), gcc-8 (at least) starts copying Blobs around, even though Blob has a move ctor. So I looked into it, and - long story short -
vector<>, in both practice and theory (the standard, cppreference), will use move ctor exclusively, if and only if:
noexcept
.I could go on and post link, but that's the basic situation.
P.S. It's still a perfectly reasonable tactic to store vector<unique_ptr> if one wants guaranteed quickness in this sense. And I do that in Flow-IPC et al where I need it. So the above is more of a general change that is required medium/long-term, since Flow is a lib (EDIT: and now open-source).
The text was updated successfully, but these errors were encountered: