In his book The C++ Programming Language (third edition) Stroustrup teaches to define individual components in their own namespace and import them in a general namespac
I feel the other answers have left out the first, simplest, and most useful way to compose namespaces: to use only what you need.
namespace Needed {
using std::string;
using std::bind;
using std::function;
using std::cout;
using std::endl;
using namespace std::placeholders;
}
int main(int argc, char* argv[])
{
/* using namespace std;
would avoid all these individual using clauses,
but this way only these are included in the global
namespace.
*/
using namespace Needed; // pulls in the composition
string s("Now I have the namespace(s) I need,");
string t("But not the ones I don't.");
cout << s << "\n" << t << endl;
// ...
Thus any conflicts with other parts of the STL are avoided,as well as the
need to preface the common used functions with std::
.