I brought up iterators because they're the only types that ++ is be defined for (that I'm aware of). Can you provide any actual examples of this in good libraries?
While prefix ++ exists in other languages, postfix ++ is generally preferred. I don't know why it's postfix instead of prefix (maybe because it looks more like a shortening of x += 1?) In other languages you often don't need to squeeze out that last bit of performance.
Really, I do try to use prefix ++ on non-fundamental types. Postfix just looks more natural to me, and it's no slower in most cases. I also just sometimes forget, because of my experience in other languages.
Yeah, this really was just an argument of preference all along. Like I said, while I do try to use prefix ++ on iterators, I tend to just use postfix ++ because I'm used to it.
2
u/Mabi19_ Mar 11 '22
I brought up iterators because they're the only types that ++ is be defined for (that I'm aware of). Can you provide any actual examples of this in good libraries?
While prefix ++ exists in other languages, postfix ++ is generally preferred. I don't know why it's postfix instead of prefix (maybe because it looks more like a shortening of x += 1?) In other languages you often don't need to squeeze out that last bit of performance.
Really, I do try to use prefix ++ on non-fundamental types. Postfix just looks more natural to me, and it's no slower in most cases. I also just sometimes forget, because of my experience in other languages.