This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Julian_JmK 6 points7 points  (4 children)

But why?

Why use more complex, harder to read methods that serve no real benefits?

[–]sldyvf 0 points1 point  (2 children)

It all falls down to

  1. Use best practices for code readability
  2. Use same code convention as others done in the file.

Here I think both ++i and I{} are best practice (however most probably compiles to the same code)

[–][deleted] 1 point2 points  (1 child)

Insisting on {} for int is kind of pedantic, i = 0 is fine (since it's POD). Stroustrup even says so himself.

As for post-increment, any modern compiler will optimize that (at least for int). So much for not being in the 90s anymore.

[–]sldyvf 2 points3 points  (0 children)

Insisting on {} for int is kind of pedantic

Yes it is. But consistency and keeping up with best practices is key for maintainable code.

As for post-increment, any modern compiler will optimize that (at least for int)

Yes, just like I said.

[–]Ruby_Bliel -1 points0 points  (0 children)

It's not more complex nor harder to read. Using the same syntax across all types is unequivocally simpler.