Why are some functions in not in the std namespace?

Implementations of the C++ standard library are permitted to declare C library functions in the global namespace as well as in std. Some would call this a mistake, since (as you’ve found) the namespace pollution can cause conflicts with your own names. However, that’s the way it is, so we must live with it. You’ll just have to qualify your name as arithmetic::sin.

In the words of the standard (C++11 17.6.1.2/4):

In the C++ standard library, however, the declarations (except for
names which are defined as macros in C) are within namespace scope (3.3.6) of the namespace std. It is
unspecified whether these names are first declared within the global namespace scope
and are then injected
into namespace std by explicit using-declarations (7.3.3).

Leave a Comment