[Issue 1835] typeof(this) should return the type of object or some other typeof() is needed
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Jul 24 09:15:26 PDT 2010
http://d.puremagic.com/issues/show_bug.cgi?id=1835
Christian Kamm <kamm-removethis at incasoftware.de> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |kamm-removethis at incasoftwar
| |e.de
Resolution| |FIXED
--- Comment #7 from Christian Kamm <kamm-removethis at incasoftware.de> 2010-07-24 09:15:23 PDT ---
Yes, it looks like template this parameters cover this use case. You can even
express the contract of a clone function nicely:
class B {
T clone(this T)() {
return (cast(T)this).cloneImpl();
}
B cloneImpl() { return new B; }
}
class D {
override D cloneImpl() { return new D; }
}
If the user forgets to provide cloneImpl or doesn't make it return the correct
type, the compiler will complain. At least as long as clone!(D) gets
instantiated somewhere.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list