| Thread overview | |||||
|---|---|---|---|---|---|
| 
 | 
| February 08, 2021Operator Overloading for Enum | ||||
|---|---|---|---|---|
| 
 | ||||
| Hi all, Is it possible to operator overload on enums? I'd like to do a opCmp() Kind regards, Mike | ||||
| February 08, 2021Re: Operator Overloading for Enum | ||||
|---|---|---|---|---|
| 
 | ||||
| Posted in reply to Michael Brown | 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,
> Mike
No, it isn't. Only structs and classes can have overloaded operators.
 | |||
| February 08, 2021Re: Operator Overloading for Enum | ||||
|---|---|---|---|---|
| 
 | ||||
| Posted in reply to Michael Brown | 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, > Mike You can create custom struct type with opCmp() and create enum with that type. Example: https://run.dlang.io/is/m7DN66 | |||
Copyright © 1999-2021 by the D Language Foundation
  Permalink
Permalink Reply
Reply