Things C++ 20 Deliberately Broke

norm norm.rowtree at gmail.com
Tue Sep 27 01:55:54 UTC 2022


On Monday, 26 September 2022 at 22:15:49 UTC, Steven 
Schveighoffer wrote:
> On 9/25/22 7:01 PM, Walter Bright wrote:
>> https://docs.google.com/presentation/d/1HwLNSyHxy203eptO9cbTmr7CH23sBGtTrfOmJf9n0ug/edit?usp=sharing&resourcekey=0-GH5F3wdP7D4dmxvLdBaMvw
>> 
>> 
>> https://news.ycombinator.com/item?id=32969957
>> 
>
> From the document:
>
> > Math between disparate enums is deprecated
>
> Why? Why can't you add one enum to another when they are based 
> on int, as long as it's typed as int?
>
> I'm honestly curious as to the problems this is solving.
>
> -Steve

Two disparate enums are not the same type and they are not int. 
Like feet and meters are both represented using float.

So C++20 take on this is if you want to do math between disparate 
enums you must explicitly cast to a common type like int, which 
states clearly on the page and to the compiler you know what 
you're doing.


More information about the Digitalmars-d mailing list