mardi 21 mai 2019

function overloads and template - how to call particular function

I have the following functions:

void fun(const std::string& x = "")
{}

template<typename T>
void fun(T t, const std::string& x = "")
{}

When T == std::string I still want to call the template version. It can be done this way:

fun<std::string>(str);

Is it possible to call the template version without a type specification ? How should I modify the above code ?

Aucun commentaire:

Enregistrer un commentaire