Re: Template argument deduction not working with template specialization

2021-01-17 Thread Paul via Digitalmars-d-learn
I just figured out half of my frustration is caused by a collision between the 'alias this'd template possibillity and the normal one. For example: struct Bar(uint size, V) { V[size] blup; alias blup this; } void foo(S : T[], T)(S a) { pragma(msg, "first"); } void foo

Re: Template argument deduction not working with template specialization

2021-01-17 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/17/21 3:41 PM, Paul wrote: On Sunday, 17 January 2021 at 16:42:27 UTC, Steven Schveighoffer wrote: This works: void TFoo(T : U[], U)(T a) Oh cool, that's surprising to say the least. Thanks! This indeed works with argument deduction :) It's basically saying if T matches the pattern

Re: Template argument deduction not working with template specialization

2021-01-17 Thread Paul via Digitalmars-d-learn
On Sunday, 17 January 2021 at 16:42:27 UTC, Steven Schveighoffer wrote: I've always hated that aspect of specialization. I don't really understand why it's valid (how can T be T[]?) I totally agree with that, that confuses me as well. This works: void TFoo(T : U[], U)(T a) Oh cool, that's

Re: Template argument deduction not working with template specialization

2021-01-17 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/17/21 11:22 AM, Paul wrote: While trying to use template specializations I noticed the argument deductions do not yield the same version as the ones yielded when being explicit. Example: uint a = 1; uint[] b = [2]; TFoo(a); TFoo!(uint[])(b); void TFoo(T)(T a) { pragma(msg, "T: " ~

Template argument deduction not working with template specialization

2021-01-17 Thread Paul via Digitalmars-d-learn
While trying to use template specializations I noticed the argument deductions do not yield the same version as the ones yielded when being explicit. Example: uint a = 1; uint[] b = [2]; TFoo(a); TFoo!(uint[])(b); void TFoo(T)(T a) { pragma(msg, "T: " ~ T.stringof); } void TFoo(T :

Re: function template specialization question D vs. C++

2018-01-14 Thread kdevel via Digitalmars-d-learn
On Sunday, 14 January 2018 at 02:24:52 UTC, Adam D. Ruppe wrote: On Sunday, 14 January 2018 at 02:14:50 UTC, Jonathan M Davis wrote: If you're using template constraints rather than template specializations, then you can't have any unconstrained templates. Not true: see the tip of the week he

Re: function template specialization question D vs. C++

2018-01-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, January 13, 2018 19:32:06 Jonathan M Davis via Digitalmars-d- learn wrote: > On Sunday, January 14, 2018 02:24:52 Adam D. Ruppe via Digitalmars-d-learn > wrote: > > On Sunday, 14 January 2018 at 02:14:50 UTC, Jonathan M Davis > > > > wrote: > > > If you're using template constraints ra

Re: function template specialization question D vs. C++

2018-01-13 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 14 January 2018 at 00:09:42 UTC, kdevel wrote: The compiler does not allow me to specialize the primary function template for double: Yes, it does., and it works for float and double. Just `real` matches both equally, so that's the error for that type. Let me quote the spec: http

Re: function template specialization question D vs. C++

2018-01-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, January 14, 2018 02:24:52 Adam D. Ruppe via Digitalmars-d-learn wrote: > On Sunday, 14 January 2018 at 02:14:50 UTC, Jonathan M Davis > > wrote: > > If you're using template constraints rather than template > > specializations, then you can't have any unconstrained > > templates. > > No

Re: function template specialization question D vs. C++

2018-01-13 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 14 January 2018 at 02:14:50 UTC, Jonathan M Davis wrote: If you're using template constraints rather than template specializations, then you can't have any unconstrained templates. Not true: see the tip of the week here http://arsdnet.net/this-week-in-d/2016-sep-04.html

Re: function template specialization question D vs. C++

2018-01-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, January 14, 2018 01:02:46 kdevel via Digitalmars-d-learn wrote: > On Sunday, 14 January 2018 at 00:30:37 UTC, Nicholas Wilson wrote: > > The usual way to do what you are trying to do is with template > > constraints. > > > > void foo(T)() if (is(T== float)) { ...} > > Thanks. That works

Re: function template specialization question D vs. C++

2018-01-13 Thread kdevel via Digitalmars-d-learn
On Sunday, 14 January 2018 at 00:30:37 UTC, Nicholas Wilson wrote: The usual way to do what you are trying to do is with template constraints. void foo(T)() if (is(T== float)) { ...} Thanks. That works but looks a bit ugly. Am I right that I have to leave out the primary (unconstrained) temp

Re: function template specialization question D vs. C++

2018-01-13 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 14 January 2018 at 00:09:42 UTC, kdevel wrote: fusp.d ``` import std.stdio; import std.typecons; void foo (T) () { writeln ("(1) foo T = ", T.stringof); } void foo (T : float) () { writeln ("(2) foo T = ", T.stringof); } // void foo (T : double) () // { //writeln ("(2) foo

function template specialization question D vs. C++

2018-01-13 Thread kdevel via Digitalmars-d-learn
not allow me to specialize the primary function template for double: $ dmd fusp.d fusp.d(23): Error: fusp.foo called with argument types () matches both: fusp.d(9): fusp.foo!real.foo() and: fusp.d(14): fusp.foo!real.foo() fusp.d(23): Error: foo!real has no effect Is this a compile

template specialization and Rebindable

2017-12-03 Thread vit via Digitalmars-d-learn
Why is template param T != B but T == Rebindable!(const(B)) when specialization is T : const(A)? abstract class A{} class B : A{} string foo(T : const(A))(T x){ return T.stringof; } void main(){ import std.typecons : Rebindable; import std.stdio : writeln; Rebindable!(const B)

Re: Template specialization question

2016-11-24 Thread Steven Schveighoffer via Digitalmars-d-learn
On Thursday, 24 November 2016 at 17:59:55 UTC, ag0aep6g wrote: Took me a bit to find it, but it is documented: "If both a template with a sequence parameter and a template without a sequence parameter exactly match a template instantiation, the template without a TemplateSequenceParameter is

Re: Template specialization question

2016-11-24 Thread Stefan Koch via Digitalmars-d-learn
On Thursday, 24 November 2016 at 17:47:04 UTC, Steven Schveighoffer wrote: void foo(T)(T t){writeln("a");} void foo(T...)(T t){writeln("b");} foo(1); Compiles? If so, which prints out? I was surprised by the answer. I can't find docs for it. Is the behavior intended? -Steve That is expect

Re: Template specialization question

2016-11-24 Thread ag0aep6g via Digitalmars-d-learn
On 11/24/2016 06:47 PM, Steven Schveighoffer wrote: void foo(T)(T t){writeln("a");} void foo(T...)(T t){writeln("b");} foo(1); Compiles? If so, which prints out? I was surprised by the answer. I can't find docs for it. Is the behavior intended? Took me a bit to find it, but it is documented:

Template specialization question

2016-11-24 Thread Steven Schveighoffer via Digitalmars-d-learn
void foo(T)(T t){writeln("a");} void foo(T...)(T t){writeln("b");} foo(1); Compiles? If so, which prints out? I was surprised by the answer. I can't find docs for it. Is the behavior intended? -Steve

Re: Template specialization

2016-01-22 Thread Ali Çehreli via Digitalmars-d-learn
On 01/22/2016 07:41 AM, Darrell Gallion wrote: Defining the template [specializations] within another function, fails. Reported: https://issues.dlang.org/show_bug.cgi?id=15592 Ali

Re: Template specialization

2016-01-22 Thread Marc Schütz via Digitalmars-d-learn
On Friday, 22 January 2016 at 13:03:52 UTC, Darrell Gallion wrote: On Friday, 22 January 2016 at 11:23:56 UTC, Marc Schütz wrote: On Friday, 22 January 2016 at 01:33:42 UTC, Darrell Gallion wrote: void foo(A)() if (!is (A == int)) { pragma(msg, "int"); } void foo(A)() if (i

Re: Template specialization

2016-01-22 Thread Darrell Gallion via Digitalmars-d-learn
On Friday, 22 January 2016 at 13:03:52 UTC, Darrell Gallion wrote: On Friday, 22 January 2016 at 11:23:56 UTC, Marc Schütz wrote: On Friday, 22 January 2016 at 01:33:42 UTC, Darrell Gallion wrote: void foo(A)() if (!is (A == int)) { pragma(msg, "int"); } void foo(A)() if (i

Re: Template specialization

2016-01-22 Thread Darrell Gallion via Digitalmars-d-learn
On Friday, 22 January 2016 at 11:23:56 UTC, Marc Schütz wrote: On Friday, 22 January 2016 at 01:33:42 UTC, Darrell Gallion wrote: void foo(A)() if (!is (A == int)) { pragma(msg, "int"); } void foo(A)() if (is (A == int[])) { pragma(msg, "int[]"); } void main() { foo!

Re: Template specialization

2016-01-22 Thread Marc Schütz via Digitalmars-d-learn
On Friday, 22 January 2016 at 01:33:42 UTC, Darrell Gallion wrote: void foo(A)() if (!is (A == int)) { pragma(msg, "int"); } void foo(A)() if (is (A == int[])) { pragma(msg, "int[]"); } void main() { foo!(int)(); foo!(int[])(); } === source\app.d(15): Erro

Re: Template specialization

2016-01-21 Thread Darrell Gallion via Digitalmars-d-learn
On Friday, 22 January 2016 at 00:08:56 UTC, Ali Çehreli wrote: On 01/21/2016 03:37 PM, Darrell Gallion wrote: How do you create a template that accepts many types. But overrides just one of them? Don't want to write out all of the specializations. Hours of google and I'm sure it's simple... -=

Re: Template specialization

2016-01-21 Thread Ali Çehreli via Digitalmars-d-learn
On 01/21/2016 03:37 PM, Darrell Gallion wrote: How do you create a template that accepts many types. But overrides just one of them? Don't want to write out all of the specializations. Hours of google and I'm sure it's simple... -=Darrell The straightforward approach is tricky because the ':

Re: Template specialization

2016-01-21 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Jan 21, 2016 at 11:37:34PM +, Darrell Gallion via Digitalmars-d-learn wrote: > How do you create a template that accepts many types. > But overrides just one of them? > Don't want to write out all of the specializations. > > Hours of google and I'm sure it's simple... [...] I'm afrai

Template specialization

2016-01-21 Thread Darrell Gallion via Digitalmars-d-learn
How do you create a template that accepts many types. But overrides just one of them? Don't want to write out all of the specializations. Hours of google and I'm sure it's simple... -=Darrell

Re: : in template specialization vs constraint

2015-12-22 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/22/15 10:40 AM, Adam D. Ruppe wrote: In specialization, it will implicitly convert, it will just select the best match available. Make #1: void func(T : ubyte)(T v) { writeln(1); } It will then use that for for the second line because it is a *better* match than :int, but :int stil

Re: : in template specialization vs constraint

2015-12-22 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 22 December 2015 at 15:29:16 UTC, Shriramana Sharma wrote: 1) At func(100) why isn't the compiler complaining that it is able to match two templates i.e. the ones printing 2 and 3? Because the specialized one just wins the context. It only complains when there's two equal ones. C

: in template specialization vs constraint

2015-12-22 Thread Shriramana Sharma via Digitalmars-d-learn
import std.stdio; void func(T)(T v) { writeln(1); } void func(T: int)(T v) { writeln(2); } void func(T)(T v) if (is(T: int)) { writeln(3); } void main() { func(100); ubyte s = 200; func(s); } The above code prints 2 twice. A fwe questions: 1) At func(100) why isn't the compiler compla

Re: Template specialization using traits?

2015-12-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, December 21, 2015 19:54:53 Shriramana Sharma via Digitalmars-d-learn wrote: > Thanks all for your replies. One question: > > Jonathan M Davis wrote: > > Alternatively, you can use static if, though you're only dealing > > with one template in that case. e.g. > > But if we wanted to depr

Re: Template specialization using traits?

2015-12-21 Thread Shriramana Sharma via Digitalmars-d-learn
Thanks all for your replies. One question: Jonathan M Davis wrote: > Alternatively, you can use static if, though you're only dealing > with one template in that case. e.g. But if we wanted to deprecate one of the alternatives, then we necessary need to declare two templates with the same name a

Re: Template specialization using traits?

2015-12-21 Thread tcak via Digitalmars-d-learn
On Monday, 21 December 2015 at 11:12:10 UTC, Jonathan M Davis wrote: On Monday, 21 December 2015 at 11:07:16 UTC, Jonathan M Davis wrote: For your example to work with template constraints, the most straightforward solution would be void func(T)(T t) if(!isIntegral!T) { writeln(1); }

Re: Template specialization using traits?

2015-12-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, 21 December 2015 at 11:07:16 UTC, Jonathan M Davis wrote: For your example to work with template constraints, the most straightforward solution would be void func(T)(T t) if(!isIntegral!T) { writeln(1); } void func(T)(T t) if(isIntegral!T) { writeln(2); } Alternati

Re: Template specialization using traits?

2015-12-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, December 21, 2015 15:14:20 Shriramana Sharma via Digitalmars-d-learn wrote: > Hello. I want to define a template specialization using traits: > > import std.stdio, std.traits; > void func(T)(T t) { writeln(1); } > void func(T)(T t) if(isIntegral!T) { writeln(2)

Re: Template specialization using traits?

2015-12-21 Thread rumbu via Digitalmars-d-learn
On Monday, 21 December 2015 at 09:44:20 UTC, Shriramana Sharma wrote: Hello. I want to define a template specialization using traits: import std.stdio, std.traits; void func(T)(T t) { writeln(1); } void func(T)(T t) if(isIntegral!T) { writeln(2); } void main() { func(1); } But I'm ge

Template specialization using traits?

2015-12-21 Thread Shriramana Sharma via Digitalmars-d-learn
Hello. I want to define a template specialization using traits: import std.stdio, std.traits; void func(T)(T t) { writeln(1); } void func(T)(T t) if(isIntegral!T) { writeln(2); } void main() { func(1); } But I'm getting an error saying that the called function matches both. If it w

Re: template specialization and template mixin

2013-05-16 Thread Andrej Mitrovic
On 5/16/13, Jack Applegame wrote: > Why this doesn't compile? I think this is a bug.

template specialization and template mixin

2013-05-16 Thread Jack Applegame
This code compiles , as expected struct A { void func(string s : "foo")() { pragma(msg, "func for foo"); } void func(string s)() { pragma(msg, "func for others: " ~ s); } } void main() { A a; a.func!"foo"(); a.func!"bar"();

Re: Checking if something is a template specialization?

2011-02-18 Thread Sean Eskapp
== Quote from Lars T. Kyllingstad (public@kyllingen.NOSPAMnet)'s article > On Fri, 18 Feb 2011 02:02:51 +, Sean Eskapp wrote: > > If I have > > > > class Bar(T) > > { > > } > > > > void foo(Y)() > > { > >... > > } > > > > Is there a way to check inside foo() that Y is in some way an > > ins

Re: Checking if something is a template specialization?

2011-02-18 Thread Lars T. Kyllingstad
On Fri, 18 Feb 2011 02:02:51 +, Sean Eskapp wrote: > If I have > > class Bar(T) > { > } > > void foo(Y)() > { >... > } > > Is there a way to check inside foo() that Y is in some way an > instantiation of Bar? Is there a way to find WHICH instantiation it is? void foo(Y)() { static

Checking if something is a template specialization?

2011-02-17 Thread Sean Eskapp
If I have class Bar(T) { } void foo(Y)() { ... } Is there a way to check inside foo() that Y is in some way an instantiation of Bar? Is there a way to find WHICH instantiation it is?

Re: function-local template specialization error

2010-07-14 Thread Don
bearophile wrote: canalpay: Thanks, But this example works: void main() { T input(T)() {} } Why ? You are right. Beside allowing nested functions (this is well known), it seems D2 also accepts the definition (with template constraint too) and instantiation of simple templates insi

Re: function-local template specialization error

2010-07-14 Thread bearophile
canalpay: > Thanks, But this example works: > void main() > { > T input(T)() > {} > > } > > Why ? You are right. Beside allowing nested functions (this is well known), it seems D2 also accepts the definition (with template constraint too) and instantiation of simple templates inside f

Re: function-local template specialization error

2010-07-14 Thread canalpay
bearophile Wrote: > In D2 you can't define templates inside functions. > > Bye, > bearophile Thanks, But this example works: void main() { T input(T)() {} } Why ?

Re: function-local template specialization error

2010-07-14 Thread bearophile
canalpay: > void main() > { > T input(T)() > {} > > T input(T : string)() > {} > } In D2 you can't define templates inside functions. Bye, bearophile

function-local template specialization error

2010-07-14 Thread canalpay
void main() { T input(T)() {} T input(T : string)() {} } Error message : isimsiz.d(6): found 'input' when expecting ';' following statement isimsiz.d(6): found ':' when expecting ')' isimsiz.d(6): found 'string' when expecting ';' following statement isimsiz.d(6): found ')' inst

Re: A module comprehensive template-specialization

2010-06-28 Thread Rory McGuire
Library in D 2.0, but failed to do so via template specialization which is put into different modules. Putting everything into one module interferes with extensibility. I tried the following: == Module a == | module a; | | template Base (T) | { | alias T Base; | } == Module b == | module b

Re: A module comprehensive template-specialization

2010-06-28 Thread Matthias Walter
On 06/28/2010 09:49 AM, Justin Spahr-Summers wrote: > On Sun, 27 Jun 2010 18:51:35 +0200, Matthias Walter > wrote: >> >> Hi list, >> >> I tried to write a traits class comparable to iterator_traits in C++ STL >> or graph_traits in Boost Graph Library in D 2.0,

Re: A module comprehensive template-specialization

2010-06-28 Thread Matthias Walter
ts arises when I want to make an existing class (who's code I cannot modify) match a Concept, in which case I would just add another template specialization for this class. Here I would have to add further conditions to the template constraints, which would also mean to modify a library. A promin

Re: A module comprehensive template-specialization

2010-06-28 Thread Justin Spahr-Summers
On Sun, 27 Jun 2010 18:51:35 +0200, Matthias Walter wrote: > > Hi list, > > I tried to write a traits class comparable to iterator_traits in C++ STL > or graph_traits in Boost Graph Library in D 2.0, but failed to do so via > template specialization which is put into differen

Re: A module comprehensive template-specialization

2010-06-27 Thread Simen kjaeraas
Matthias Walter wrote: Can I handle this in another way (like making the template a conditional one)? Template constraints[1] sounds like what you want. Basically, you want the following: == Module a == | module a; | | template Base (T) if (!is(T t : t*)) | { | alias T Base; | } == Modul

A module comprehensive template-specialization

2010-06-27 Thread Matthias Walter
Hi list, I tried to write a traits class comparable to iterator_traits in C++ STL or graph_traits in Boost Graph Library in D 2.0, but failed to do so via template specialization which is put into different modules. Putting everything into one module interferes with extensibility. I tried the

Re: template specialization

2010-06-10 Thread Larry Luther
Thanks everyone.

Re: template specialization

2010-06-09 Thread Trass3r
Please write one, overloading of functions with templates is an important and basic thing. http://d.puremagic.com/issues/show_bug.cgi?id=3941

Re: template specialization

2010-06-09 Thread bearophile
Steven Schveighoffer: > I know this is planned, because it's in TDPL. BTW, are there any bug > reports for this? Please write one, overloading of functions with templates is an important and basic thing. Bye, bearophile

Re: template specialization

2010-06-09 Thread Steven Schveighoffer
On Tue, 08 Jun 2010 17:25:43 -0400, Larry Luther wrote: This code: import std.stdio; class A { void get (T:ubyte)(T[] buffer) { writefln( "get (T:ubyte)(T[] buffer)\n"); } void get (T:byte)(T[] buffer) { writefln( "get (T:byte)(T[] buffer)\n"); } void get (T)(T[] buffe

Re: template specialization

2010-06-09 Thread Steven Schveighoffer
On Tue, 08 Jun 2010 17:25:43 -0400, Larry Luther wrote: This code: import std.stdio; class A { void get (T:ubyte)(T[] buffer) { writefln( "get (T:ubyte)(T[] buffer)\n"); } void get (T:byte)(T[] buffer) { writefln( "get (T:byte)(T[] buffer)\n"); } void get (T)(T[] buffe

Re: template specialization

2010-06-08 Thread Don
Larry Luther wrote: Thanks guys. Simen asked: "Is there a problem?". Well, I kind of expected a "ubyte" buffer to be matched with a "get(T:ubyte)". I thought methods were searched for the "best" match. No, C++ does it that way, and it gets horrendously complicated. In D, it has to ma

Re: template specialization

2010-06-08 Thread Larry Luther
Thanks guys. Simen asked: "Is there a problem?". Well, I kind of expected a "ubyte" buffer to be matched with a "get(T:ubyte)". I thought methods were searched for the "best" match. Larry

Re: template specialization

2010-06-08 Thread Ellery Newcomer
On 06/08/2010 05:01 PM, Robert Clipsham wrote: On 08/06/10 22:25, Larry Luther wrote: Q: Is this the way it's supposed to be? Yes, byte implicitly casts to ubyte so it's accepted. Try switching the templates round, they will both be byte. The way around this is to add template constraints to t

Re: template specialization

2010-06-08 Thread Robert Clipsham
On 08/06/10 22:25, Larry Luther wrote: Q: Is this the way it's supposed to be? Yes, byte implicitly casts to ubyte so it's accepted. Try switching the templates round, they will both be byte. The way around this is to add template constraints to the templates: void get(T:ubyte)(T[] buffer)

Re: template specialization

2010-06-08 Thread Simen kjaeraas
Larry Luther wrote: get (T:ubyte)(T[] buffer) get (T:ubyte)(T[] buffer) get (T)(T[] buffer) Q: Is this the way it's supposed to be? Looks very much correct, yes. Is there a problem? -- Simen

template specialization

2010-06-08 Thread Larry Luther
This code: import std.stdio; class A { void get (T:ubyte)(T[] buffer) { writefln( "get (T:ubyte)(T[] buffer)\n"); } void get (T:byte)(T[] buffer) { writefln( "get (T:byte)(T[] buffer)\n"); } void get (T)(T[] buffer) { writefln( "get (T)(T[] buffer)\n"); } } void main

Re: template specialization question

2010-02-01 Thread Ellery Newcomer
On 02/01/2010 07:29 PM, Ali Çehreli wrote: daoryn wrote: > According to http://digitalmars.com/d/2.0/template.html it is possible to specify template specialization so that DMD prefers them when instanciating templates, however the following c

Re: template specialization question

2010-02-01 Thread Ali Çehreli
daoryn wrote: > According to http://digitalmars.com/d/2.0/template.html it is possible to specify template specialization so that DMD prefers them when instanciating templates, however the following code: > > > - > import std.stdio; > >

Re: template specialization question

2010-02-01 Thread Ellery Newcomer
On 02/01/2010 04:19 PM, daoryn wrote: The whole point of specialisation (and of templates in general) is to have functions that work for any type. Having to forcibly specify a type is like casting to a specific overload of a function. Why add clutter to the syntax when the language advertises

Re: template specialization question

2010-02-01 Thread daoryn
Tomek Sowiński Wrote: > Dnia 31-01-2010 o 21:39:21 Ali Çehreli napisał(a): > > > � wrote: > >> Dnia 31-01-2010 o 20:59:47 Tomek Sowi�ski napisa�(a): > >> > >>> // specialization needed to limit matching types > >>> void print(T:int)(T thing) > >> To be clear -- I did this to silence t

Re: template specialization question

2010-02-01 Thread daoryn
it a compiler bug or misinterpreted template specialization?

Re: template specialization question

2010-02-01 Thread daoryn
y whether this belongs in bugzilla or not. It might. > > On 01/31/2010 12:49 PM, daoryn wrote: > > > > > I expected it to output "calling print(T[])" on the second "print". Would > > this be a bug or did I misunderstand the template specialization?

Re: template specialization question

2010-02-01 Thread daoryn
Daniel Murphy Wrote: > daoryn Wrote: > > > According to http://digitalmars.com/d/2.0/template.html it is possible to > > specify template specialization so that DMD prefers them when instanciating > > templates, ho

Re: template specialization question

2010-01-31 Thread Tomek Sowiński
Dnia 31-01-2010 o 21:39:21 Ali Çehreli napisał(a): � wrote: Dnia 31-01-2010 o 20:59:47 Tomek Sowi�ski napisa�(a): // specialization needed to limit matching types void print(T:int)(T thing) To be clear -- I did this to silence the compiler saying the call with array matches more than one

Re: template specialization question

2010-01-31 Thread Ali Çehreli
� wrote: Dnia 31-01-2010 o 20:59:47 Tomek Sowi�ski napisa�(a): // specialization needed to limit matching types void print(T:int)(T thing) To be clear -- I did this to silence the compiler saying the call with array matches more than one function template declaration. I'm not sure whether

Re: template specialization question

2010-01-31 Thread Tomek Sowiński
Dnia 31-01-2010 o 20:59:47 Tomek Sowiński napisał(a): // specialization needed to limit matching types void print(T:int)(T thing) To be clear -- I did this to silence the compiler saying the call with array matches more than one function template declaration. I'm not sure whether the comp

Re: template specialization question

2010-01-31 Thread Tomek Sowiński
Dnia 31-01-2010 o 19:49:44 daoryn napisał(a): import std.stdio; void print(T)(T thing) { writeln("Calling print(T)"); writeln(T.stringof); } void print(T:T[])(T[] things) { writeln("Calling print(T[])"); writeln(T.stringof); } void main() { print(3);

Re: template specialization question

2010-01-31 Thread Ellery Newcomer
ot;calling print(T[])" on the second "print". Would this be a bug or did I misunderstand the template specialization?

Re: template specialization question

2010-01-31 Thread Daniel Murphy
daoryn Wrote: > According to http://digitalmars.com/d/2.0/template.html it is possible to > specify template specialization so that DMD prefers them when instanciating > templates, however the following code: > > > - > import std.stdio;

template specialization question

2010-01-31 Thread daoryn
According to http://digitalmars.com/d/2.0/template.html it is possible to specify template specialization so that DMD prefers them when instanciating templates, however the following code: - import std.stdio; void print(T)(T thing) { writeln("Ca