Re: How to declare a template type as parameter to functions

2014-11-03 Thread Domingo via Digitalmars-d-learn
Here is my pull request https://github.com/D-Programming-Language/dlang.org/pull/690 Please anyone feel free to improve it. Cheers !

Re: How to declare a template type as parameter to functions

2014-11-03 Thread Domingo via Digitalmars-d-learn
Thanks again the bug issue is there at https://issues.dlang.org/show_bug.cgi?id=13677 But probably I should fork the repository and fix myself !

Re: How to declare a template type as parameter to functions

2014-11-03 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Nov 04, 2014 at 12:48:47AM +, Domingo via Digitalmars-d-learn wrote: > Thanks again this second explanation now is easier to understand as > general rule for this case and future ones that I'll face in the > future. > > I hope that this explanation would be added to the language refere

Re: How to declare a template type as parameter to functions

2014-11-03 Thread Domingo via Digitalmars-d-learn
Thanks again this second explanation now is easier to understand as general rule for this case and future ones that I'll face in the future. I hope that this explanation would be added to the language reference where it explain functions: http://dlang.org/function With it there people will

Re: How to declare a template type as parameter to functions

2014-11-03 Thread Domingo via Digitalmars-d-learn
Now I realize that what I said on the previous post is not correct. Based on the proposed use of typeof/alias we will need something like this: alias MongoCurosr3NUll = MongoCursor!(Bson, Bson, typeof(null)); alias MongoCursor3Bson = MongoCursor!(Bson, Bson, Bson); alias MongoCursor3IntStr =

Re: How to declare a template type as parameter to functions

2014-11-03 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Nov 04, 2014 at 12:29:54AM +, Domingo via Digitalmars-d-learn wrote: [...] > Like the "simple" function that I tried to write to not duplicate code > is not worth because I'll need to write one for each type of > MongoCursor: > > 1 - MongoCursor!(Bson, Bson, typeof(null)) > 2 - MongoCu

Re: How to declare a template type as parameter to functions

2014-11-03 Thread Domingo via Digitalmars-d-learn
Thanks for the answer ! But then I can see that using D style templates everywhere will prevent write generic code and what seems to be an innocent function call will explode to bloated mass of code. Like the "simple" function that I tried to write to not duplicate code is not worth because

Re: How to declare a template type as parameter to functions

2014-11-03 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Nov 03, 2014 at 11:43:42PM +, Domingo via Digitalmars-d-learn wrote: > Hello ! > > I could not find a clear way that show how to use template types as > parameter to functions: > > There is a general rule to do it ? On several examples when the return type > comes from a template I sa

Re: How to declare a template type as parameter to functions

2014-11-03 Thread Domingo via Digitalmars-d-learn
One of the problems I'm facing from vibed (but I'm asking a general rule to help here and in other similar cases): protected void sendCollectionListAsDataArrayJson2(MongoCursor!(Bson,Bson,Bson) collection_list, HTTPServerResponse res) { if(!collection_list.empty) {

How to declare a template type as parameter to functions

2014-11-03 Thread Domingo via Digitalmars-d-learn
Hello ! I could not find a clear way that show how to use template types as parameter to functions: There is a general rule to do it ? On several examples when the return type comes from a template I saw the usage of "auto" where the compiler will deduce the correct type but when we need to