new DIP40: Template parameter deduction for constructors

Timon Gehr timon.gehr at gmx.ch
Tue May 14 02:44:30 PDT 2013


On 05/14/2013 09:28 AM, Timothee Cour wrote:
>         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.
>
>     No it is not. The DIP states "find all constructors".
>
>
> it said  'Find all matching class/struct types in scope', isn't that
> enough or am I missing something?
>

Apparently. The point is that it is not always possible to determine all 
constructors before the template is instantiated. The DIP must state 
when and how it works and what happens if it does not.

> To clarify, I've added 3 out of scope structs named A in the example
> section to clarify that they won't be included in the overload set.
> see the ones marked '//not in scope'
>

I don't get this. (Also, why is it relevant to the discussion?)

The following declaration:

template A(T1){
struct A{ //not in scope unless T1 is explicitly instantiated
     this()(T1 a) {}
}
}

Is the same declaration, modulo constraint, as the preceding

struct A(T1)
if (!isNumeric!T1)
{
     this()(T1 a) {}
}




More information about the Digitalmars-d mailing list