to namespace or not to namespace?

Started by
13 comments, last by SiCrane 18 years, 8 months ago
i use namespaces a lot in libraries, why? because i like to know what piece of code i am currently using on the first view without having to browse through headerfiles

thats why i keep namespace names pretty short and usually use only 2 levels

i personally like to encapsulate every piece of code i write into a library for later reuse, this shall reduce the development time of my projects by ways on the long term and in conjunction with a decent IDE that can do namespace browsing like the VC IDEs this saves another huge amount of time

no more browsing of a huge global namespace with tons of entries


so in a few words, i use them for clean code and reduced production times
http://www.8ung.at/basiror/theironcross.html
Advertisement
Quote:Original post by Monder
Quote:when does namespace partitioning become an overhead?


Depends what you mean by overhead. It definitely won't effect anything performance wise.


Aside from possibly negatively affecting the performance of dynamic_cast and/or adding bloat for RTTI structures.
Quote:
Aside from possibly negatively affecting the performance of dynamic_cast and/or adding bloat for RTTI structures.


I stand corrected, thanks for pointing that out. Though if such penalties did occur I doubt they'd have much of an impact.
They only expand the textual representation of the types name, which is a minor additional bit of memory per class, not per instance. The name is mangled into a single globally unigue identifier that includes all the namespace names and template parameters but not a single colon.
Quote:Original post by Deyja
They only expand the textual representation of the types name, which is a minor additional bit of memory per class, not per instance. The name is mangled into a single globally unigue identifier that includes all the namespace names and template parameters but not a single colon.

What you describe is an implentation specific behavior. Compilers other than yours may work differently. For example, an implementation is free to stick the colons into the string returned when you call std::type_info::name(), or even store the colons internally to do string match ups in dynamic_casts.

This topic is closed to new replies.

Advertisement