On Tuesday 01 March 2011 22:18:49 Bekenn wrote:
> Code:
> 
>       class MyException : Exception
>       {
>               this(string message, string file, size_t line, Throwable next = 
> null)
>               {
>                       super(message, file, line, next);
>               }
> 
>               this(string file = __FILE__, size_t line = __LINE__)(string 
> message,
> Throwable next = null)
>               {
>                       this(message, file, line, next);
>               }
>       }
> 
>       void main()
>       {
>               throw new MyException("Bluh!");
>       }
> 
> Error message:
> 
>       test.d(8): Error: template test.MyException.__ctor(string file =
> __FILE__,size_t line = __LINE__) conflicts with constructor
> test.MyException.this at test.d(3)
> 
> If I remove the normal constructor and call super instead of this from
> the constructor template, then I get this slightly different error message:
> 
>       test.d(1): Error: constructor test.MyException.this conflicts with
> template test.MyException.__ctor(string file = __FILE__,uint line =
> __LINE__) at test.d(3)
> 
> Is this a compiler bug, or am I Doing It Wrong?

You cannot currently templatize class constructors:

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

And currently if one overload of a function is templatized, _all_ overloads of 
that function must templatized:

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

- Jonathan M Davis

Reply via email to