logoalt Hacker News

cv5005yesterday at 6:27 PM3 repliesview on HN

One reason is that c++ still hasn't gotten 'trivial relocatability' right - i.e being able to memcpy/memmove and not have to call constructors/destructors when growing your vector class.


Replies

Panzerschrekyesterday at 6:49 PM

Actually, issues with non-trivial moves and relocations are specific only for C++. Some other languages (notably Rust and Swift) don't have such issues, but still have nice automatic memory management via destructors and containers atop of it.

Panzerschrekyesterday at 6:44 PM

C++ compilers optimize-out empty destructor calls and sometimes even replace calls to move constructors/move assignment operators via memcpy. But it's unfortunately not guaranteed in all cases due to constrains of the C++ object/memory model designed initially without proper move semantics.

tardedmemeyesterday at 9:25 PM

std::is_trivially_copyable says hi