On Wednesday, 3 May 2017 at 12:46:19 UTC, Andrej Mitrovic wrote:
On Wednesday, 3 May 2017 at 09:13:54 UTC, Daniel N wrote:
However I oppose the other part of the DIP since it's already possible today.

class FileException : Exception
{
this(ErrorCode error_code, string file = __FILE__, uint line = __LINE__ )
    {
        super("FileNotFound", file, line);
    }

    alias __ctor = super.__ctor;
}

I was excited for a second, but that doesn't actually compile.

Error: alias test.FileException.__ctor is not a constructor; identifiers starting with __ are reserved for the implementation

I used this technique many times with many different compiler versions...

The trick is that your child class need to have defined at least 1 constructor before the alias.

This should work:
this() {}
alias __ctor = super.__ctor;

This will give the error message you saw:
alias __ctor = super.__ctor;
this() {}

Reply via email to