logoalt Hacker News

1718627440last Monday at 8:32 PM1 replyview on HN

I find passing by value to be sensible, but the allocating part sounds like a bad idea. Passing the value of something doesn't imply making a copy, if the value is never changed, it can be entirely optimized away.


Replies

spacechild1last Monday at 11:08 PM

> Passing the value of something doesn't imply making a copy

Yes, languages like Rust can automatically move variables if the compiler can prove that they will not be used anymore. Unfortunately, this is not possible in C++, so the user has to move explicitly (with std::move).

show 1 reply