Advertisement
Danol

D bug report #1

Jan 11th, 2014
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
D 0.74 KB | None | 0 0
  1. module ming.mc.test;
  2.  
  3.  
  4. struct enumf( T = ushort ) {
  5.  
  6. public:
  7.   alias val this;
  8.  
  9. public:
  10.   T val = 1;
  11.  
  12. public:
  13.   this( T val ) {
  14.     this.val = val;
  15.   }
  16.   this( int val ) {
  17.     this.val = cast( T ) val;
  18.   }
  19.  
  20. public:
  21.   void opAssign( int val ) {
  22.     this.val = cast( T ) val;
  23.   }
  24.  
  25.   enumf!T opBinary( string op : "+" )( T add ) {
  26.     return enumf!T( val << add );
  27.   }
  28.   int opCmp( enumf!T other ) {
  29.     if( other.val == val )
  30.       return 0;
  31.     else if( val > other.val )
  32.       return 1;
  33.     else
  34.       return -1;
  35.   }
  36.  
  37. }
  38.  
  39. enum F {
  40.   halCenter = enumf!ushort(),
  41.   halRight,
  42.  
  43.   valCenter = enumf!ushort( 2 ),
  44.   valRight = enumf!ushort( 1 )
  45. }
  46.  
  47. //>> Error: no property 'max' for type 'enumf!ushort'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement