[Issue 4423] [tdpl] enums of struct types
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Thu Aug 7 13:40:59 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=4423
hsteoh at quickfur.ath.cx changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
CC| |hsteoh at quickfur.ath.cx
Resolution|--- |WORKSFORME
--- Comment #6 from hsteoh at quickfur.ath.cx ---
Works in git HEAD. Full test code:
------
struct S
{
this(string phrase, int num)
{
this.phrase = phrase;
this.num = num;
}
int opCmp(const ref S rhs)
{
if(phrase < rhs.phrase)
return -1;
else if(phrase > rhs.phrase)
return 1;
if(num < rhs.num)
return -1;
else if(num > rhs.num)
return 1;
return 0;
}
string phrase;
int num;
}
enum E : S {a = S("hello", 1),
b = S("goodbye", 45),
c = S("world", 22)};
void main() {
import std.stdio;
E e;
writeln(e.phrase);
e = E.b;
writeln(e.phrase);
}
------
Program output:
------
hello
goodbye
------
--
More information about the Digitalmars-d-bugs
mailing list