digitalmars.D.learn - Operator Overloading for Enum
- Michael Brown (5/5) Feb 08 2021 Hi all,
- Paul Backus (3/8) Feb 08 2021 No, it isn't. Only structs and classes can have overloaded
- DolphinChips (3/8) Feb 08 2021 You can create custom struct type with opCmp() and create enum
Hi all, Is it possible to operator overload on enums? I'd like to do a opCmp() Kind regards, Mike
Feb 08 2021
On Monday, 8 February 2021 at 15:56:24 UTC, Michael Brown wrote:Hi all, Is it possible to operator overload on enums? I'd like to do a opCmp() Kind regards, MikeNo, it isn't. Only structs and classes can have overloaded operators.
Feb 08 2021
On Monday, 8 February 2021 at 15:56:24 UTC, Michael Brown wrote:Hi all, Is it possible to operator overload on enums? I'd like to do a opCmp() Kind regards, MikeYou can create custom struct type with opCmp() and create enum with that type. Example: https://run.dlang.io/is/m7DN66
Feb 08 2021