When using a header which has a format
, an implementation will put names into std
namespace. And it may put names into the global namespace as well, as it is described here:
[ Example: The header
assuredly provides its declarations and definitions within the namespace std. It may also provide these names within the global namespace. [...] — end example ]
Is there a (maybe compiler dependent) way to circumvent/disable this behavior (I'm open to any tricky solution)? I'd like to use names from std
only, and I'd like to have an error/warning when using names from the global namespace:
#include
double a = cos(0.5); // I'd like to have an error here, because std:: is missing
The reasons:
- It is hard to write a portable code, if it may use names from the global namespace, as these names may be not available in other compilers. It is much cleaner to use everything from
std
, and not use the global namespace at all cos(0.5f)
does a different thing whetherstd::
is prefixed or not (float
vsdouble
result).
No comments:
Post a Comment