new DIP40: Template parameter deduction for constructors
timotheecour
timothee.cour2 at gmail.com
Tue May 14 00:06:11 PDT 2013
On Tuesday, 14 May 2013 at 03:20:59 UTC, Kenji Hara wrote:
> Currently conditional compilation would stop IFTI.
>
> template foo(T)
> {
> static if (is(T == int))
> void foo(T) {}
> }
> void main()
> {
> foo(1); // shouldn't work
> }
>
> Same as above, DIP40 should prevent following case.
>
> template foo(T)
> {
> struct foo
> {
> static if (is(T == int))
> this(T) {}
> }
> }
> void main()
> {
> foo(1); // also should not work
> }
>
> Kenji Hara
I think that should be consistent with the deduction mechanism
proposed in the DIP:
foo is struct not in scope until template foo(T) is instantiated.
More information about the Digitalmars-d
mailing list