digitalmars.D.bugs - [Issue 17713] New: Template 'this' parameters for static methods
- via Digitalmars-d-bugs (44/44) Aug 03 2017 https://issues.dlang.org/show_bug.cgi?id=17713
https://issues.dlang.org/show_bug.cgi?id=17713 Issue ID: 17713 Summary: Template 'this' parameters for static methods Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: enhancement Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: timon.gehr gmx.ch Template 'this' parameters should work even when the method is static. For example: mixin template Constructors(){ this(){ } this()immutable{ } this()shared{ } } class A { public: static C getInstance(this C)() { return new C(); } private: mixin Constructors; } class B : A { private: mixin Constructors; } void main(){ auto a = A.getInstance(); auto b = B.getInstance(); static assert(is(typeof(a)==A)); static assert(is(typeof(b)==B)); auto ai = (immutable(A)).getInstance(); auto bs = (shared(B)).getInstance(); static assert(is(typeof(ai)==immutable(A))); static assert(is(typeof(bs)==shared(B))); } Also see: http://forum.dlang.org/post/olv6se$1ohc$1 digitalmars.com --
Aug 03 2017