Having multiple namespaces minimizes the likelihood of problems with an alias. Everything from the standard library should be within std:: , ok, but the standard library is still quite large for a single namespace. For example, in std::filesystem you have the function std::filesystem::status . It is easy to imagine other parts of the library where the status function may be needed at some point. And the namespace also gives a clearer purpose or βdomainβ function when reading code.
Also, if you, for example, using namespace std; at some point in your code, you may have some kind of status function in the current namespace, so this will allow you not to repeat std:: without pulling every thing from the standard library directly into the local namespace or more selectively select a specific subset the names you want to make.
However, breaking an API into uncountable namespaces is also not too practical. Perhaps someone more familiar with the C ++ standardization process can give a more complete answer with details on how the committee decides when to add the namespace, but in the end it is a question of design and style, and there are no unambiguous, undeniable rules .
jdehesa
source share