Deduction of Template Value Parameters

Steven Schveighoffer schveiguy at yahoo.com
Wed Nov 3 07:19:28 PDT 2010


On Tue, 02 Nov 2010 21:56:44 -0400, gg <noreply at now.pl> wrote:

> Why we cant deduce value parameter of templates:
> void caracterize(uint m)(pp!(m)){
> 	
> }
> class pp(uint m){
>
> }
> void main(){
> 	caracterize(pp!5);
> }
> fails with
>
> dmd chap.d
> chap.d(8): Error: template chap.caracterize(uint m) does not match any  
> function template declaration
> chap.d(8): Error: template chap.caracterize(uint m) cannot deduce  
> template function from argument types !()(void)
>
> Or at least of a way to extract template instantiation information would  
> be useful. Or  it is needed to do it the long way

I think there is a way to do this, but I think you have to include the  
pp!(m) parameter, something like:

caracterize(m, T : pp!m)(pp!(m) arg)

Look through phobos' source, you will probably find someone else has  
solved the problem.

-Steve


More information about the Digitalmars-d mailing list