c++: notes on namespace

Boris Kolpackov boris at kolpackov.net
Wed Apr 21 14:35:29 CDT 2004

Some time ago I wrote:
> @@ Namespace models: 'flat' (like std::) and 'tree' (with nested
>    namespaces).
> @@ A 'tree' model can potentially be transformed into a 'flat' 
>    model via using-directives.
> @@ In the 'tree' model the outer namespace is usually for name-
>    clash avoidance; the inner namespaces are for the concept 
>    grouping.

Recently I discovered one interesting advantage of the tree model
over the flat model: when you say 

  using namespace std;

you make all names in the standard library accessible from this 
point. When you say

  using namespace std::mm;

you know you have access only to memory-management-related names. In
other words, it feels more comfortable to use using-directive in a 
tree-like namespace organization that in a flat one.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 652 bytes
Desc: Digital signature
Url : http://www.kolpackov.net/pipermail/notes/attachments/20040421/181c61f0/attachment.bin

More information about the notes mailing list