C++11 学习笔记-01.目录

前提

C++11,为什么是11呢,因为在2011年发布的版本。
C++11又叫做C++2.0

对于C++11,下面的笔记主要是谈新东西,找一些好用的东西.观看的视频是侯捷的C++11视频教程


对于各种编译器平台支持的C++
https://en.cppreference.com/w/cpp/compiler_support

三个常用的网站

[cppreference]https://zh.cppreference.com/
[cplusplus]http://www.cplusplus.com/

推荐的几本书

在这里插入图片描述

推荐全文检索工具

  • evethring
  • fiepro

推荐编辑器和工具

  • cmake
  • gcc/g++ linux
  • minggw32/64
  • qtcreater
  • vscode

查看C++版本

#include <iostream>
int main()
{
	std::cout<<__cplusplus;
}

C++ Statndard

  • C++98 (1.0)
  • C++ 03 (TR1)
  • C++ 11(2.0)
  • C++ 14

C++标准库头文件

不在使用.h,推荐使用

核心列表

  • Variadic Templates
  • move Semantics
  • auto
  • Range-base for loop
  • auto
  • Range-base for loop
  • Initializer list
  • Lambdas

C++11


C++11是第二个专业的C++版本(之前的一个版本是C++98,下一个版本是C++17)并且是自C++98版本后最重要的更新。这是一个重大版本的改变是引入了及既规范了现有的实践,又提高了C++程序员可用的抽象。

在2011年8月12日ISO最终批准之前,使用了“C++ 0x”的名字,因为它预计在2010之前发布。它在C++ 03和C++ 11之间花费了8年,因此它已经成为迄今为止版本之间最长的间隔。从C++11后起,C++经常每3年更新一次。(C++11,C++14,C++17,C++20)

以下特征合并为C++ 11:

  • 来自TR1:除特殊功能外的所有TR1。
  • 来自Boost:The thread library, exception_ptr, error_code and error_condition,
    iterator improvements (std::begin, std::end, std::next, std::prev)
  • From C: C-style Unicode转换函数

核心语言特征


  • auto and decltype
  • defaulted and deleted functions
  • final and override
  • trailing return type
  • rvalue references
  • move constructors/move assignment
  • scoped enums
  • constexpr and literal types
  • list initialization
  • delegating and inherited constructors
  • brace-or-equal initializers
  • nullptr
  • long long
  • char16_t and char32_t
  • type aliases
  • variadic templates
  • generalized unions
  • generalized PODs
  • Unicode string literals
  • user-defined literals
  • attributes
  • lambda expressions
  • noexcept
  • alignof and alignas
  • multithreaded memory model
  • thread-local storage
  • GC interface
  • range for (based on a Boost library)
  • static assertions (based on a Boost library)

库功能

头文件

<typeindex>
<type_traits>
<chrono>
<initializer_list>
<tuple>
<scoped_allocator>
<cstdint>
<cinttypes>
<system_error>
<cuchar>
<array>
<forward_list>
<unordered_set>
<unordered_map>
<random>
<ratio>
<cfenv>
<regex>
<atomic>
<thread>
<mutex>
<future>
<condition_variable>

库功能

  • atomic operations library
  • emplace() and other use of rvalue references throughout all parts of the existing library
  • std::initializer_list
  • stateful and scoped allocators
  • forward_list
  • chrono library
  • ratio library
  • new algorithms
  • Unicode conversion facets
  • The thread library
  • exception_ptr
  • error_code and error_condition
  • iterator improvements:
  • std::begin
  • std::end
  • std::next
  • std::prev
  • Unicode conversion functions

编辑器支持情况

https://zh.cppreference.com/w/cpp/compiler_support#C.2B.2B11_features

C++11 核心语言功能特性

C++11功能特性 提案 GCC Clang MSVC AppleClang EDGeccp IntelC++ IBMXLC++ Sun/OracleC++ EmbarcaderoC++Builder Cray PortlandGroup(PGI) Nvidianvcc HPaCC DigitalMarsC++
C99预处理器 N1653 4.3 19.0*(部分)19.26 4.1 11.1 10.1 5.9 8.4 2015 7 A.06.25
static_assert N1720 4.3 2.9 16.0* 4.1 11 11.1 5.13 8.4 2015 7 A.06.25 8.52
右角括号 N1757 4.3 14.0* 4.1 11 12.1 5.13 8.4 2015 7
扩展的friend声明 N1791 4.7 2.9 16.0*(部分)18.0* 4.1 11.1(部分)12.0 11.1 5.13 8.4 2015 7 A.06.25
longlong N1811 14.0* 8.4 2015 7
类型特征的编译器支持 N1836 4.3 3 14.0* 4 10 13.1.3 5.13 8.4 2015 6.16
auto N1984 4.4 16.0* 3.9 11.0(v0.9)12.0 11.1 5.13 8.4 2015 7 A.06.25
委托构造函数 N1986 4.7 3 18.0* 4.7 14 11.1 5.13 8.4 2015 7 A.06.28
externtemplate N1987 3.3 12.0* 3.9 9 11.1 5.13 8.4 2015 7 A.06.25
constexpr N2235 4.6 3.1 19.0* 4.6 13.0(部分)14.0 12.1(部分)13.1 5.13 8.4 2015 7 A.06.28
模板别名 N2258 4.7 3 18.0* 4.2 12.1 13.1.1* 5.13 8.4 2015 7 A.06.27
char16_t与char32_t N2249 4.4 2.9 19.0* 4.4 12.1*14.0 13.1.1* 5.13 8.4 2015 7 A.06.27 8.52
alignas N2341 4.8 3 19.0* 4.8 15 13.1.2* 5.13 8.6 2015 7
alignof N2341 4.5 2.9 19.0* 4.8 15 13.1.2* 5.13 8.4 2015 7
默认化与被删除的函数 N2346 4.4 3 18.0* 4.1 12 13.1 5.13 8.4 2015 7 A.06.25
强类型enum N2347 4.4 2.9 17.0* 4 13 12.1 5.13 8.4 2015 7 A.06.25
原子操作 N2427 4.4 3.1 17.0* Yes 13 13.1.2* 5.14 8.4 2015
nullptr N2431 4.6 2.9 16.0* 4.2 12.1 13.1 5.13 8.4 2015 7 A.06.27 8.52
显式转换运算符 N2437 4.5 3 18.0* 4.4 13 12.1 5.13 8.4 2015 7 A.06.27
引用限定符 N2439 4.8.1 2.9 19.0* 4.7 14 13.1.2* 5.13 8.4 2015 7 A.06.28
Unicode字符串字面量 N2442 4.4 3 19.0* 4.7 11.0* 10.113.1.1 5.7 8.4 2015 7 A.06.28 8.52
未处理的字符串字面量 N2442 4.5 18.0* 4.7 14 13.1.1* 5.13 8.4 2015 7 A.06.28 8.52
内联命名空间 N2535 4.4 2.9 19.0* 4.5 14 11.1 5.13 8.4 2015 7 A.06.28
继承构造函数 N2540 4.8 3.3 19.0* 4.8 15 13.1.1* 5.13 8.4 2015 7
尾随的函数返回类型 N2541 4.4 2.9 16.0* 4.1 12.1 5.13 8.4 2015 7 A.06.27
无限制的联合体 N2544 4.6 3 19.0* 4.6 14.0* 13.1.2* 5.13 8.4 2015 7 A.06.28
变参数模板 N2242N2555 4.3(N2242)4.4 2.9 18.0* 4.3(N2242)4.3 12.1 11.1(N2242) 5.13 8.4 2015 7 A.06.27
表达式SFINAE N2634 4.4 2.9 19.14* 4.2 12.1 8.4 2015 7
局部与无名类型作为模板形参 N2657 4.5 2.9 16.0* 4.2 12 13.1.2* 5.13 8.4 2015 7 A.06.27
线程局部存储 N2659 4.4(部分)4.8 3.3* 16.0*(部分)19.0* 4.8 11.1(部分)15.0* 10.1(部分)13.1.2(部分) 5.9(部分) 8.4 2015 8.52(部分)
带并发的动态初始化与析构(魔法静态变量) N2660 4.3 2.9 19.0* Yes 11.1* 13.1.2* 5.13 8.4 2015 A.06.25
垃圾收集与基于可达性的泄漏检测 N2670
初始化器列表 N2672 4.4 3.1 18.0* 4.5 13.0(部分)14.0 13.1.2* 5.13 8.4 2015 7 A.06.28
非静态数据成员初始化器 N2756 4.7 3 18.0* 4.6 14 13.1.2* 5.13 8.4 2015 7 A.06.28
属性 N2761 4.8 3.3 19.0* 4.2 12.1 13.1.1* 5.13 8.4 2015 7 A.06.27
前置enum声明 N2764 4.6 3.1 17.0* 4.5 11.1(部分)14.0 12.1 5.13 8.4 2015 7
用户定义的字面量 N2765 4.7 3.1 19.0* 4.8 15 13.1.2* 5.14 8.4 2015 7
右值引用 N2118N2844CWG1138 4.3(N2118)4.5 2.9 16.0*(N2844)17.0* 4.5 11.1(N2118)12.0(N2844)14.0 12.1 5.13 8.4 2015 7.0* A.06.25
Lambda表达式 N2550N2658N2927 4.5 3.1 16.0*(N2658)17.0* 4.1 12 13.1.2* 5.13 8.4 2015 7 A.06.25
范围for循环 N2930 4.6 3 17.0* 4.5 13 13.1.2* 5.13 8.4 2015 7 A.06.28
noexcept N3050 4.6 3 19.0* 4.5 14 13.1.1* 5.13 8.4 2015 7 A.06.28
默认化的移动特殊成员函数 N3053 4.6 3 19.0* 4.5 14 5.13 8.4 2015 7 A.06.25
override与final N2928N3206N3272 4.7 2.9 14.0*(部分)17.0* 4.8 12.0(N2928)14.0 13.1.1* 5.13 8.4 2015 7
decltype N2343N3276 4.3(N2343)4.8.1 2.9 16.0* 4.2(N2343)4.8 11.0(N2343)12.0 11.1(N2343) 5.13 8.4 2015 7 A.06.25 8.52(N2343)
C++11功能特性 提案 GCC Clang MSVC AppleClang EDGeccp IntelC++ IBMXLC++ Sun/OracleC++ EmbarcaderoC++Builder Cray PortlandGroup(PGI) Nvidianvcc HPaCC DigitalMarsC++

C++11 库功能特性

C++11功能特性 提案 GCClibstdc++ Clanglibc++ AppleClang MSVC标准库 Sun/OracleC++标准库 EmbarcaderoC++Builder标准库 CrayC++标准库
类型特征 N1836 4.3 3 14.0* 5.13 8.4
垃圾收集与基于可达性的泄漏检测(库支持) N2670 6(无操作) 3.4(无操作) 是(无操作) 19.0*(无操作)
金额、时间及十六进制浮点I/O操纵符 N2071N2072 5 3.8 19.0* 5.15
C++11功能特性 提案 GCClibstdc++ Clanglibc++ AppleClang MSVC标准库 Sun/OracleC++标准库 EmbarcaderoC++Builder标准库 CrayC++标准库
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章