C++11老关键字的新含义(auto, using,extern)
来源:互联网 发布:广数980g76编程实例 编辑:程序博客网 时间:2024/06/05 15:39
出处:http://blog.csdn.net/cnsword/article/details/8034947
C++11对关键字进行了修订,加入了nullptr、constexpr、decltype、default、static_assert等,同时原有的关键字(auto,using,extern)含义和用途进行了修订。在这里主要了解一下对auto、using、extern这三个关键字的修订。
auto
自动化变量
auto a = 12;auto b = 12.0f;auto c = true;auto d = [] (int x)->int{ return 12;};auto e = std::bind(&func, _1);
延迟绑定
template<typename T, typename L>auto fun(T x, L y)->decltype(x + y){return x;}
using
定义别名
template<typename T>using Tlist = std::list<T>;
using Tlist = std::list<char>;
using df = void(*)();//等价于typedef void(*df)()
和typedef的区别:C++11标准7.1.3.2:( https://isocpp.org/files/papers/N3690.pdf )
- 定义一般类型的别名没区别。
2 A typedef-name can also be introduced by an alias-declaration. The identifier following the using keyword becomes a typedef-name and the optional attribute-specifier-seq following the identifier appertains to that typedef-name. It has the same semantics as if it were introduced by the typedef specifier. In particular, it does not define a new type and it shall not appear in the type-id. [Example:using handler_t = void (*)(int);extern handler_t ignore;extern void (*ignore)(int); // redeclare ignoreusing cell = pair<void*, cell*>; // ill-formed— end example ]
- 定义模板的别名,只能使用using。
使用外部构造
using A::A;
引入外部类型
using typename A;
extern
外部模板
extern template<typename T>void(T t);
0 0
- C++11老关键字的新含义(auto, using,extern)
- C++11老关键字的新含义(auto, using,extern)
- 关键字auto 含义 -- C
- c存储类型的关键字auto extern static regisger
- C语言auto、register、static、extern关键字
- c++11的新特性---auto关键字
- extern "C"的含义
- “extern c”的含义
- C/C++中涉及存储方式的关键字:auto,static,register,extern
- C语言中关键字auto、static、register、const、volatile、extern的作用
- C/C++中涉及存储方式的关键字:auto,static,register,extern
- C语言中关键字auto、static、register、const、volatile、extern的作用
- C语言中关键字auto、static、register、const、volatile、extern的作用
- C语言中关键字auto、static、register、const、volatile、extern的作用
- C语言中关键字auto、static、register、const、volatile、extern的作用
- C语言中关键字auto、static、register、const、volatile、extern的作用
- C语言中关键字auto、static、register、const、volatile、extern的作用
- C语言中关键字auto、static、register、const、volatile、extern的作用
- Spring+Spring MVC+Mybatis框架整合详细教程
- 异常向量表
- jQueryUI-autocomplete的使用
- idea配置maven
- 浅谈动态规划(三)
- C++11老关键字的新含义(auto, using,extern)
- 程序的调用机制及目标文件有什么
- ubuntu14.04上使用glfw
- CPUFreq驱动随笔(一)
- 页面置换算法及磁盘调度算法
- yii2.0目录结构
- 【Luogu】 P1726 上白泽慧音
- 零基础学习wince开发-环境搭建
- A1014. Waiting in Line (30)