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

B

bb

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.
 
A

Alf P. Steinbach

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

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/.

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?

Of course: it is a relevant consideration.


Cheers, & hth.,

- Alf
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top