[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 16:18:42 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=1835



--- Comment #8 from Fawzi Mohamed <fawzi at gmx.ch> 2010-07-24 16:18:40 PDT ---
Yes indeed and Christian showed this templates argument allows one workaround
to achieve this (a wrapper object is another).

{{{
class A {
  void a(...){ ... }
  T aChain(this T)() {
   a();
   return cast(T)this;
  }
}
class B {
  void a(...){ ... }
}
}}}

it might even be cleaner to have also a non chainable version, the return this
is really a convenience, and not strictly part of the operation itself, even if
it implies some duplication.

-- 
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