News for hackers. Stuff that matters.
Re:C++ is faster and safer than Rust (2020) by ohgodplsno on Thursday October 07, 2021 @03:08AM (#28783157)
Allow me introduce operator overloading, where I have suddenly defined a ++ operator on my god object that contains a 50MB pool. This operator increments a single field in it, and I really need it because I do it so often.

++godobject will simply increment that value.

godobject++ will make a copy of that object, returning it to you along with allocating another 50MB pool, purely to increment the value.

Re:C++ is faster and safer than Rust (2020) by makapuf on Friday October 08, 2021 @01:26AM (#28796027)
That's what I meant with operator++ being redefined to do anything.
Re:C++ is faster and safer than Rust (2020) by jcelerier on Friday October 08, 2021 @07:34AM (#28798055)
but when you write generic algorithms (as you should), you don't know beforehand with which "operator++" your a will be called. So you have to go for the one which will give the best performance.