Consider the following two using
statements:
using ::space1::space2::MyType;
using MyType = ::space1::space2::MyType;
It seems that after the using
, both ways allows us the use MyType
directly (without any qualifiers).
So what's the difference between the above two?
As said in the comment, in the first case you are actually exporting a name from a namespace to the one which contains the using
declaration, while in the second case you are defining an alias in the namespace that contains the using
statement that points to that specific name and its surrounding namespace.
As an example, with the second expression you can define aliases like the following one:
using Foo = Bar<MyClass>;
template <class C>
using Foo = Bar<C, MyClass>;
While the first using
expression cannot, it serves merely to let names to be available in different spaces than the ones that contain them.
See here for further details regarding using directives, using declarations and aliases (type and template ones).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With