Date: Fri, 14 Mar 2025 13:02:22 +0100
The main reason for integral types (probably) is well-defined comparison.
Some floating point types allow 0+0 and 0-0 or more exotic #NaN and #Inf values.
You also want to make sure that rounding errors won't make two values the same, which are not.
From this, it kind of follows that the representation should be more or less defined (perhaps you can allow a bijective mapping).
If you want 4 types, you could just create
struct { int x, y, z, w; }
or use
std::tuple
I believe, the ++ increment is only needed, if no values are given or you use ...
-----Ursprüngliche Nachricht-----
Von:Filip <fph2137_at_[hidden]>
Gesendet:Fr 14.03.2025 12:48
Betreff:Re: [std-proposals] lambdas in enums
An:std-proposals_at_[hidden];
CC:Sebastian Wittmeier <wittmeier_at_[hidden]>; std-proposals_at_[hidden];
Yes it could, but maybe we shouldn’t limit ourselves with types of enum to just integral types.
Maybe the only things that should be considered is ++ and construction at compile time.
In this example we could just use std::pair but what if you want 4 types?
Cheers, Filip
Wiadomość napisana przez Sebastian Wittmeier via Std-Proposals <std-proposals_at_[hidden]> w dniu 14 mar 2025, o godz. 12:43:
The enum in this case could have a std::pair<int, float> as fundamental type instead.
Wouldn't that be simpler and more flexible, as this class (in this case std::pair) could provide added functionality, e.g. suitable constructors.
-----Ursprüngliche Nachricht-----
Von:Filip <fph2137_at_[hidden]>
Gesendet:Fr 14.03.2025 12:33
Betreff:Re: [std-proposals] lambdas in enums
An:std-proposals_at_[hidden];
CC:Sebastian Wittmeier <wittmeier_at_[hidden]>; std-proposals_at_[hidden];
sizeof an enum is essentially a sizeof its underlying type, so it should be the sum of sizeof of each type.
C and D are valid.
if the compiler can ( and should ) compare them and optimize the storage, then it could be optimized.
However then you would ensure that operator== is implemented for it to be used.
Cheers, Filip
--
Std-Proposals mailing list
Std-Proposals_at_[hidden]
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
Received on 2025-03-14 12:07:31