dimanche 29 octobre 2017

sqrt being defined multiple places (xtgmath)

I include the c+ header <cmath>, rather than math.h and expect a function like sqrt to then be defined in std as std::sqrt, but to my surprise resharper kept insisting that std was redundant in writing std::sqrt

After some digging, it turns out that there is a sqrt in the global namespace and after digging even more, it comes from including <vector> which in turn includes xtgmath.h which defines sqrt in the global namespace.

Vector being a modern header (as in not named .h), this is a bit surprising to me.

I guess, apart from the annoying resharper notification, it doesn't really matter, since I can still explicitly write std::sqrt and be sure which I get, but then again, I could forget the std somewhere and effectively randomly be using a different implementation, which seems a bit off to me.

Am I seeing problems where none are? What is the proper way to deal with this?

Aucun commentaire:

Enregistrer un commentaire