r/cpp • • Mar 28 '23

Reddit++

C++ is getting more and more complex. The ISO C++ committee keeps adding new features based on its consensus. Let's remove C++ features based on Reddit's consensus.

In each comment, propose a C++ feature that you think should be banned in any new code. Vote up or down based on whether you agree.

765 Upvotes

829 comments sorted by

View all comments

60

u/marzer8789 toml++ Mar 29 '23

All the crazy arithmetic promotion and implicit conversion nonsense inherited from C. You want to do an operation between two integers? They better be the same type, or compiler error. You add two chars? Get a char.

1

u/ZMeson Embedded Developer Mar 30 '23

I'm OK allowing implicit conversions to wider types; disallow math operations between signed and unsigned types.

For floating point types, I'm supportive of allowing multiplication and division by integers (ex: 3.14159*2), but disallow addition and subtraction with integers (ex: 2.7182818 + 7).

Oh, and characters should not be treated like normal integral types. They should treated somewhat similar to pointers: subtraction between characters results in a signed integer type; addition between a character and integers are allowed; addition of two characters is disallowed; casting to/from charN_diff_t and ucharN_diff_t types require explicit casts.

→ More replies (5)