opIs broke for structs?

Era Scarecrow rtcvb32 at yahoo.com
Sat Oct 13 14:40:04 PDT 2012


  I'm curious why this would break and not work, as is should 
compare against it's location/entity correct? I wonder why it 
breaks then for structs on the stack. I can only find 'opIs 
missing' when searching for it, so...

struct X {
   int x;
}

class Y {
   int y;
}

   Y y1 = new Y();
   Y y2 = new Y();
   X x1, x2;

   assert(y1.y == y2.y);
   assert(y1 !is y2);
   assert(y1 != y2); //same as !is by default as i recall

//  writefln("x1 = 0x%s\nx2 = 0x%s", &x1, &x2);
   assert(x1 == x2);
   assert(x1 !is x2); //fails


More information about the Digitalmars-d-learn mailing list