Nested namespaces, go or no go?

Started by
1 comment, last by Radikalizm 11 years, 6 months ago
Like the title states, is it a good idea to nest namespaces inside of each other (i.e. Foo::Bar::Baz::Qux(int n))?
what
Advertisement
In principle, there's nothing wrong with it, just make sure that actually having different namespaces actually makes sense for the size and scope of the project. Ex: boost has a number of nested namespaces, but boost contains a large number of different libraries, many of which are completely unrelated to each other. On the other hand, if your entire program can fit in two source files, then nested namespaces are probably a bad idea.
I like to use nested namespaces when working on a large project which can actually be divided in logical groups of code, like separating a math library from a rendering library found in a single project for example. It's not exactly necessary, but it can really help with maintaining an overview of your code.

But as SiCrane mentioned, it's not a good idea to use them for smaller projects.

I gets all your texture budgets!

This topic is closed to new replies.

Advertisement