News for hackers. Stuff that matters.
Re:Don’t blindly prefer emplace_back to push_back by MauranKilom on Thursday March 04, 2021 @07:25AM (#26341479)
Indeed. I recently looked at using std::deque because I was exactly trying to avoid allocating too much contiguous memory, fearing fragmentation.

Sadly, std::deque is pretty much useless. It uses something like page-sized blocks in one implementation, a few cachelines in another one (forgot which is gcc/clang), and on MSVC it allocates every single item separately (!!!) for element size > 1 word. And this will not be changed due to ABI compatibility. It might as well not exist in the standard.

Re:Don’t blindly prefer emplace_back to push_back by gpderetta on Thursday March 04, 2021 @07:49AM (#26341669)
yes, I never use std::deque for the same reason. I believe that the deque in boost these days has a compile time configurable block size.