News for hackers. Stuff that matters.
Re:C++ is faster and safer than Rust (2020) by jcelerier on Thursday October 07, 2021 @04:24PM (#28791604)
> a++; means do nothing

only if a is a very simple thing. plenty of "advanced" containers actually do things ; in the "a++" case they have to save the previous state to return a copy, in the "++a" case they don't. If your iterator for instance contains a std::vector<int> to maintain some internal state for a multidimensional dynamic matrix, then in one case you'll get a simple increment, in the other a whole dynamic allocation / free which may be optimized out by the compiler in release mode and definitely won't in debug mode

Re:C++ is faster and safer than Rust (2020) by makapuf on Saturday October 09, 2021 @04:15AM (#28807975)
That is increment a part, for whatever is being defined as incrementing for this class. If you define different things for post and pre increment they will cost differently, sure. If the compiler decides to do more than what I told to, it will be longer. But will a++ always cost more than ++a?
Re:C++ is faster and safer than Rust (2020) by jcelerier on Sunday October 10, 2021 @06:29AM (#28817294)
> If you define different things for post and pre increment

They are defined as different things. One returns the current value and increments, the second increments the current value and returns it. In the first case you have to cache the previous value, in the second you don't. If your operators don't do that they are bugged and wrong.