[Issue 323] New: Error: need opCmp for class Bar
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Sep 3 12:14:03 PDT 2006
http://d.puremagic.com/issues/show_bug.cgi?id=323
Summary: Error: need opCmp for class Bar
Product: D
Version: unspecified
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: bugzilla at digitalmars.com
ReportedBy: someanon at yahoo.com
I think this use to work; now on Linux dmd.166, it reports:
Error: need opCmp for class Bar
============================================
template Valuable(T) {
protected:
float m_value = 0.0;
public:
float value() {return m_value;}
void value(float v) {m_value=v;}
int opCmp(T other) {
int r;
if (value < other.value) {r = -1;}
else if (value > other.value) {r = 1;}
return r;
}
}
class Foo {
}
class Bar : Foo {
mixin Valuable!(Bar); // defined opCmp to compare Bar
public:
this(float v) {
m_value = v;
}
}
int main(char[][] args) {
Bar[3] bars;
for (int i = 0; i < 3; i++) {
bars[i] = new Bar(i);
}
bars.sort;
return 0;
}
============================================
--
More information about the Digitalmars-d-bugs
mailing list