Multiple aliases for a namespace?

C++

C++ Problem Overview


Is it possible to have a namespace that has all the declarations of more than one other namespace? Like this:

namespace std {...};
namespace glm {...};

namespace mynamespace = std; //mynamespace is an alias for std
namespace mynamespace += glm; //mynamespace will hold glm functions as well.

C++ Solutions


Solution 1 - C++

Sure

namespace mynamespace
{
   using namespace std;
   using namespace glm;
}

Solution 2 - C++

You can use using to achieve this:

namespace mynamespace {
    using namespace std;
    using namespace glm;
}

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionPilpelView Question on Stackoverflow
Solution 1 - C++ForEveRView Answer on Stackoverflow
Solution 2 - C++alainView Answer on Stackoverflow