mercredi 25 février 2015

Is it ok to put "using std::swap;" in a header?


I've read that when you're swaping things in c++, you should always using std::swap;, then call swap unqualified, so it automatically picks the std:: ones for std:: and builtin types, your custom one for custom types, and the templated std:: one for everything else.


So, can I just put using std::swap; in the header that every file includes and not have to worry about it?


I understand that avoiding using in a header is common practice. However, is there a problem with it in this particular case?




Aucun commentaire:

Enregistrer un commentaire