Is there a standard alias for a class name inside class code?

Something like 'this' referring to a class instance, but referring instead to the class itself?

What i would like to do is have something like

class Clas {
   // alias Clas THIS; <- don't want this boilerplate
   static THIS make_instance( .... ) {
       auto x = new THIS( );
       ....
       return x;
   }
}

This would be great for copy/paste, changing class names, and in general communicating your intention.

I'm guessing the answer is no, and that there's some compelling reason why a compiled language wouldn't want to provide this feature. (But the php interpreter, whatever else is good or bad about it, does let you write 'new self(...)' and does the right thing with it.)

TIA for any clues.

dan

Reply via email to