// Called with doSomething<5>();
template<unsigned i_>
void doSomething()
{
std::cout << i_ << '\n';
}
// Called with doSomething(5);
void doSomething(unsigned i_)
{
std::cout << i_ << '\n';
}
When is the first option preferred? Why is it even available? I understand it's useful for classes where the arguments in angle brackets are tied to the object itself, not a specific constructor, but is it useful for functions?
Aucun commentaire:
Enregistrer un commentaire