我知道在C++11中,我们现在可以使用using来编写类型别名,例如typedefs:
typedef int MyInt;据我所知,相当于:
using MyInt = int;这种新语法来自于努力找到一种表达“模板typedef”的方法:
template< class T > using MyType = AnotherType< T, MyAllocatorType >;但是,对于前两个非模板示例,标准中还有其他细微的差异吗?例如,typedef确实存在“弱”混淆现象。也就是说,它不创建新类型,而只创建新名称(这些名称之间的转换是隐含的)。
它和using是一样的还是生成了一个新类型?有什么区别吗?