Item 9: 比起typedef更偏爱别名声明(alias declaration)

来源:互联网 发布:sqlserver存储过程语法 编辑:程序博客网 时间:2024/06/05 17:35

本文翻译自《effective modern C++》,由于水平有限,故无法保证翻译完全正确,欢迎指出错误。谢谢!

我确信我们都同意使用STL容器是一个好主意,并且我希望在Item 18中能让你相信使用std::unique_ptr也是一个好主意,但是我猜想,我们中没有任何一个人想多次写这样的类型:“std::unique_ptr

            你要记住的事
  • typedef不支持模板化,但是别名声明(alias declaration)支持。

  • alias templates避免了“::type”后缀,以及在template中“typename”前缀(当代表一个类型时)的使用。

  • C++14提供所有C++11 type traits 转换的alias templates版本。
0 0
原创粉丝点击