How to declare a template type as parameter to functions

Domingo via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Nov 3 16:40:37 PST 2014


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 = MongoCursor!(Bson, Bson, int[string]);

then call my function like this:

sendCollectionListAsDataArrayJson2!MongoCurosr3NUll( 
MongoCurosr3NUllParam, res);

sendCollectionListAsDataArrayJson2!MongoCursor3Bson( 
MongoCursor3BsonParam, res);

sendCollectionListAsDataArrayJson2!MongoCursor3IntStr( 
MongoCursor3IntStrParam, res);


I do not think this way of writing code is "DRY" or easy to 
write/read/understand, it seems that D code will end up been a 
crypt one a la "perl" !!!

No offense here to perl but some write code style used on it.

!!!!! Please help here to make this clear for me and future D 
language users !!!!!!!

Cheers !


More information about the Digitalmars-d-learn mailing list