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 pass that value as a parameter to a function how we declare then as parameter ?


//void dummFunction(type<Bson,Bson,Bson> "appender", type<forFromAuto> "another templated type")

void dummFunction(typeforFromAuto "appender", typeforFromAuto "another templated type")
{
}

auto as = appender!string();
auto an = appender!double();
auto an = appender!customType();
auto bd = collection.find().limit(2);

struct MongoCursor(Q = Bson, R = Bson, S = Bson);

auto bd2 = collection.find(Bson(["key": Bson(3)])).limit(2);
auto bd3 = collection.find(Bson(["key": Bson(3)]), ["fld":1, "data":1]).limit(2);

The above example is dummy example only imagine that you need to write a function accepting one of the several templated types returned on several parts of phobos and third party libraries like vibed.

Can someone give a general rule for this kind of problem ?

Reply via email to