vendredi 1 juillet 2022

Why sometimes calling template function needs angle bracket and full type specification and sometimes not? [duplicate]

I have been confused by this for a while. Say if I want to call std::make_shared I usually have to specify the type I am making using std::make_shared<MyClass>(...) but I don't think angle brackets are needed in every situation. One example is the print function for {fmt} library: it is a template function, but when you call it you can do something like this: fmt::print("Elapsed time: {0:.2f} seconds", 1.23);, without fully specifying the types. I am just wondering why the difference and what's the rule governing when an angle bracket is needed when calling a template function?

Aucun commentaire:

Enregistrer un commentaire