Thread overview | |||||
---|---|---|---|---|---|
|
January 23, 2014 Template specialization | ||||
---|---|---|---|---|
| ||||
import std.stdio; class D : X{} class X{} template t1(T : void function(T)){enum t1 = "1.";} template t1(T : void function(X)){enum t1 = "2.";} int main(string[] argv){ t1!(void function(D)).writeln(); readln(); return 0; } this code prints 1. on dmd and gdc but on ldc it prints 2. Which one is correct? |
January 23, 2014 Re: Template specialization | ||||
---|---|---|---|---|
| ||||
Posted in reply to Daniel Kozak | On 01/23/2014 01:44 PM, Daniel Kozak wrote:
> import std.stdio;
>
> class D : X{}
>
> class X{}
>
>
> template t1(T : void function(T)){enum t1 = "1.";}
> template t1(T : void function(X)){enum t1 = "2.";}
>
> int main(string[] argv){
> t1!(void function(D)).writeln();
> readln();
> return 0;
> }
>
> this code prints 1. on dmd and gdc but on ldc it prints 2.
>
> Which one is correct?
1. is correct. LDC will presumably print 1. as well as soon as it is updated to a more recent frontend version.
|
January 23, 2014 Re: Template specialization | ||||
---|---|---|---|---|
| ||||
Posted in reply to Timon Gehr | Timon Gehr píše v Čt 23. 01. 2014 v 15:42 +0100:
> On 01/23/2014 01:44 PM, Daniel Kozak wrote:
> > import std.stdio;
> >
> > class D : X{}
> >
> > class X{}
> >
> >
> > template t1(T : void function(T)){enum t1 = "1.";}
> > template t1(T : void function(X)){enum t1 = "2.";}
> >
> > int main(string[] argv){
> > t1!(void function(D)).writeln();
> > readln();
> > return 0;
> > }
> >
> > this code prints 1. on dmd and gdc but on ldc it prints 2.
> >
> > Which one is correct?
>
> 1. is correct. LDC will presumably print 1. as well as soon as it is updated to a more recent frontend version.
OK, thanks
|
Copyright © 1999-2021 by the D Language Foundation