Why there is just one namespace 'std' in the std library?

Why there is just one namespace 'std' in the std library?

Post by bb » Sat, 08 Sep 2007 16:30:01


Hi,

Is there any specific reason(s) that there is only one namespace
'std' in the standard library?

e.g. namespaces are not really independent, name collisions etc.

Should one consider not introducing too many namespaces while
designing a new system ground up?

Thanks in advance.
 
 
 

Why there is just one namespace 'std' in the std library?

Post by Alf P. Ste » Sat, 08 Sep 2007 16:52:21

* bb:

There is only one top-level namespace 'std', but there is at least one
nested namespaces, namely 'std::rel_ops'.

And I think that's the only one.

I don't find it remarkable that there's only one top-level namespace
'std', but I think the single nested namespace 'std::rel_ops' /is/
remarkable. Why is it there? And the answer is simple: because many
programmers tend to write 'using namespace std;', but would not like to
then have the standard library's operators imposed on them, i.e. that in
this special case the namespaces is /needed/.



?



Of course: it is a relevant consideration.


Cheers, & hth.,

- Alf