当前位置:C++技术网 > 资讯 > C++11新改变(简单描述)

C++11新改变(简单描述)

更新时间:2015-07-28 17:28:42浏览次数:1+次

资料从wiki获取,一个个列出来C++11
https://en.wikipedia.org/wiki/C%2B%2B11#Core_language_runtime_performance_enhancements

比较简单的总结,如果你觉得可以去深入学习一下的话,可以根据关键词百度

个人比较喜欢 1、2、5、6、7、9、11、15、19、20、23虽然有一部分现在还没有用过,不过我觉得这个还是比较有用的。


1、右值引用 Rvalue
2、初始化序列
3、匿名函数
4、常量表达式constexpr关键字
5、auto自动类型
6、override函数不同参数重载
7、final不能被重载
8、默认构造函数,construtor() = defualt
9、nullptr_t 标准类型 和int、float、double、char同一层次。独立的一个类型
10、 nullptr
11、初始化可以直接显式
class aa()
{
    int i = 10;
    int b = 20;
    
}

12、枚举类型enum class Enumeration{} 及枚举值的类型如int  char
13、The using syntax can be also used as type aliasing in C++11
typedef void (*FunctionType)(double);       // Old style
using FunctionType = void (*)(double); // New introduced syntax
14、联合体的成员类型
union U {
    int z;
    double w;
    Point p; // Illegal in C++03; legal in C++11.
    U() {new(&p) Point();} // Due to the Point member, a constructor definition is now required.
};

15、U文字编码表达
u8"I'm a UTF-8 string."
u"This is a UTF-16 string."
U"This is a UTF-32 string."

16、 = delete;禁止调用某个函数
17、static_assert 静态编译警告,例子用于模板的类型使用限制,如限制一个模板,有几个类型可以用
18、sizeof 新功能
struct SomeType { OtherType member; };

sizeof(SomeType::member); // Does not work with C++03. Okay with C++11
19、支持多线程std::thread,锁std::mutex, std::recursive_mutex
20、std::tuple 和 pair是同一层次 前者用于三个组合,后者用于两个组合
21、Hash tables(哈希表) set、multiset、map、multimap都有哈希排序版
22、Regular expressions(正则表达式)
23、std::unique_ptr 和 std::shared_ptr是一个级别的
24、随机数产生器linear_congruential_engine、subtract_with_carry_engine、mersenne_twister_engine
25、多种数学分布函数,gamma_distribution(gamma分布)、negative_binomial_distribution(泊松分布)、normal_distribution(正态分布)等等20个分布
26、Wrapper reference,std::ref用于模板库的引用变量传值问题
27、<functional>头文件、很难理解的模板库运用
28、后面的两三条,没有看懂所以没有写下来了。