new DIP40: Template parameter deduction for constructors

Timon Gehr timon.gehr at gmx.ch
Tue May 14 00:14:29 PDT 2013


On 05/14/2013 09:06 AM, timotheecour wrote:
> 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:

No it is not. The DIP states "find all constructors".

> foo is struct not in scope until template foo(T) is instantiated.




More information about the Digitalmars-d mailing list