Difference between type alias and using-declaration

时间秒杀一切 提交于 2021-01-27 07:19:39

问题


Is there any difference between using a type alias and alias template on the one hand and using-declaration on the other hand defined as follows:

Given a class definition in a namespace scope:

namespace ns1
{
template< typename T >
struct A {};
}

And given another namespace, which introduces the A symbol by two different ways. First of them is type alias (alias template):

namespace ns2
{
template< typename T >
using A = ns1::A< T >; // match type-id
}

Second one is using-declaration:

namespace ns2
{
using ns1::A;
}

Is there any difference for ADL and for any other using contexts in ns1 scope (reopened), in ns2 scope or in outer scope?

来源:https://stackoverflow.com/questions/33602658/difference-between-type-alias-and-using-declaration

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!