Description
Filed by @ygoldfeld pre-open-source:
Probably all move ctors here – but also look at ipc
– should be noexcept
. Also look at noexcept
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:
- there is no copy ctor (such as with unique_ptr) in the stored type T
- the move ctor is
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).