Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple aliases for a namespace? [duplicate]

Tags:

c++

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. 
like image 421
Pilpel Avatar asked Dec 14 '15 11:12

Pilpel


People also ask

How to alias namespace in c++?

C++ Namespaces Namespace alias A namespace can be given an alias (i.e., another name for the same namespace) using the namespace identifier = syntax. Members of the aliased namespace can be accessed by qualifying them with the name of the alias.

Can we create alias of a namespace?

You can also create an alias for a namespace or a type with a using alias directive.

How to use alias in c#?

In the first use case, you define a scope, at the end of which an object is disposed. In the second use case, you create an alias for a namespace or import specific types from other namespaces. In the third use case, you import members of a single class with the static directive.

What is the use of using namespace std in C++?

The using namespace statement just means that in the scope it is present, make all the things under the std namespace available without having to prefix std:: before each of them.


2 Answers

Sure

namespace mynamespace {    using namespace std;    using namespace glm; } 
like image 153
ForEveR Avatar answered Sep 25 '22 21:09

ForEveR


You can use using to achieve this:

namespace mynamespace {     using namespace std;     using namespace glm; } 
like image 27
alain Avatar answered Sep 23 '22 21:09

alain