On 2013-05-09 11:48, Jacob Carlborg wrote:

This won't work. You need to be able to overload on static, which you
can't. I've tried this with opDispatch.

To elaborate. Below is your original with the "foo" method added.

class S
{
   static @property S instance()
   {
      if (_i is null) // #1
         _i = new S();

      return _i;
   }

   static S _i;

   alias instance this;  // #2

   void foo () {}
}

If you try to call it like this: S.foo(), the compiler will complain that "foo" need access to "this". The "alias this" won't kick in.

--
/Jacob Carlborg

Reply via email to