digitalmars.D.bugs - [Issue 5459] New: comparison of interfaces not implemented
- d-bugmail puremagic.com (46/46) Jan 17 2011 http://d.puremagic.com/issues/show_bug.cgi?id=5459
- d-bugmail puremagic.com (8/8) Jan 17 2011 http://d.puremagic.com/issues/show_bug.cgi?id=5459
http://d.puremagic.com/issues/show_bug.cgi?id=5459 Summary: comparison of interfaces not implemented Product: D Version: D2 Platform: Other OS/Version: Windows Status: NEW Keywords: patch Severity: normal Priority: P2 Component: druntime AssignedTo: sean invisibleduck.org ReportedBy: simen.kjaras gmail.com PST --- Currently, object.di's global opEquals function does not support comparing interfaces. The following code adds such support, but may add bloat due to duplicated code for all type combinations: /************************ * Returns true if lhs and rhs are equal. */ equals_t opEquals(T, U)(T lhs, U rhs) if ((is(T == class) || is(T == interface)) && (is(U == class) || is(U == interface))) { // If aliased to the same object or both null => equal if (lhs is rhs) return true; // If either is null => non-equal if (lhs is null || rhs is null) return false; // If comparison is supported via opEquals, use it static if (__traits(compiles,{lhs.opEquals(rhs) && rhs.opEquals(lhs);})) { // If same exact type => one call to method opEquals if (typeid(lhs) is typeid(rhs) || typeid(lhs).opEquals(typeid(rhs))) return lhs.opEquals(rhs); // General case => symmetric calls to method opEquals return lhs.opEquals(rhs) && rhs.opEquals(lhs); } else static assert( false, T.stringof ~ " cannot be compared to a " ~ U.stringof ); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 17 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5459 Simen Kjaeraas <simen.kjaras gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|normal |enhancement -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 17 2011