Thread overview
[Issue 11905] Can't make enum of custom struct types autoincrement working
Apr 13, 2017
Daniel Čejchan
Dec 17, 2022
Iain Buclaw
Feb 11, 2023
Basile-z
June 09, 2015
https://issues.dlang.org/show_bug.cgi?id=11905

Andrei Alexandrescu <andrei@erdani.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|unspecified                 |D2

--
April 13, 2017
https://issues.dlang.org/show_bug.cgi?id=11905

Daniel Čejchan <czdanol@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |czdanol@gmail.com

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=11905

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P2                          |P3

--
February 11, 2023
https://issues.dlang.org/show_bug.cgi?id=11905

Basile-z <b2.temp@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |b2.temp@gmx.com
         Resolution|---                         |WORKSFORME

--- Comment #2 from Basile-z <b2.temp@gmx.com> ---
This is working since 2.099 and the test suite contains a similar test to

---
struct enumf( T = ushort ) {

    enum max = T.max;


  alias val this;
  T val = 1;
  this( T val ) {
    this.val = val;
  }
  this( int val ) {
    this.val = cast( T ) val;
  }

  void opAssign( int val ) {
    this.val = cast( T ) val;
  }

  enumf!T opBinary( string op : "+" )( T add ) {
    return enumf!T( val << add );
  }

  int opCmp( enumf!T other ) {
    if( other.val == val )
      return 0;
    else if( val > other.val )
      return 1;
    else
      return -1;
  }

}

enum F {
  halCenter = enumf!ushort(),
  halRight,
  valCenter = enumf!ushort( 2 ),
  valRight = enumf!ushort( 1 )
}
---

--