关于C++11 模板中的 using

using

C++ 11 后的类型别名或者模板别名

类型别名是指:之前定义的类型的引用(类似 typedef)

模板别名是指:模板类的引用

语法:

(1)using identifier attr(optional) = type-id;

(2)template

using identifier attr(optional) = type-id

identifier : 你自己声明的变量名,可以是类型名或者模板名

type-id: 抽象类型

例子:

(1)using line_no = std::vector::size_type;

相当于:typedef vector::size_type line_no;

(2)// typedef void (func)(int, int);

usingfunc=void(
)(int,int);// the name 'func' now denotes a pointer to function

(3)template

using mystring = std::basic_string>;

mystring str;

原文链接: https://www.cnblogs.com/codingtao/p/6027423.html

欢迎关注

微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍

原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/243342

非原创文章文中已经注明原地址,如有侵权,联系删除

关注公众号【高性能架构探索】,第一时间获取最新文章

转载文章受原作者版权保护。转载请注明原作者出处!

(0)
上一篇 2023年2月13日 下午11:11
下一篇 2023年2月13日 下午11:11

相关推荐