Tag: using declaration

C ++ 11中“typedef”和“using”有什么区别?

我知道在C ++ 11中,我们现在可以using typedef s using类型别名: typedef int MyInt; 据我所知,相当于: using MyInt = int; 这种新的语法来自于努力去表达“ template typedef ”: template< class T > using MyType = AnotherType< T, MyAllocatorType >; 但是,在前两个非模板的例子中,标准还有其他的细微差别吗? 例如, typedef以“弱”方式进行别名。 也就是说,它不会创建新的类型,而只是一个新的名称(这些名称之间的转换是隐含的)。 它是using相同还是生成一个新的类型? 有什么区别?