最全C++11/14/17/20/23 的新特性代码案例

最全C++11/14/17/20/23 的新特性代码案例

来源 https://zhuanlan.zhihu.com/p/389895793

https://github.com/isocpp/CppCoreGuidelines

C++11新特性

关键字

新增关键字

含义变化或者新增含义关键字(meaning changed or new meaning added)

 

类型支持(基本类型、RTTI、类型特性)

Defined in header <type_traits>

 

STL容器

无序容器

元组std::tuple

hash

 

智能指针

 

正则表达式

 

函数

非静态成员函数

函数对象模板

 

 

模板

 

原子操作

 

线程

 

异常

 

错误

 

新语法

预处理

C++宏(cplusplus macro)

基于范围的for语句

对齐支持(alignment support)

显式转换操作符(explicit conversion operators)

静态断言(static assert)

  • 语法:static_assert(常量表达式,"提示字符串")
  • static assert

数字限制(numeric limits)

原始字符串(raw string)

追踪返回类型语法(trailing return type syntax)

扩展的friend语法(extended friend syntax)

扩展的整型(extended integer types)

非受限联合体(unrestricted union)

内联名字空间(lnline namespace)

用户定义的字面量(user-defined literals)

强类型枚举(scoped and strongly typed enums)

随机装置(random device)

std::ref和std::cref

常量表达式(constexpr)

lamda表达式

指针空值(nullptr)

防止类型收窄(Preventing narrowing)

初始化列表(initializer lists)

统一的初始化语法和语义(Uniform initialization syntax and semantics)

POD(plain old data)

long long整型

移动语义(move semantics)

右值引用(rvalue reference)

c99特性(c99)

一般化的SFINAE规则(generalized SFINAE rules)

 

C++14新特性

类型支持(基本类型、RTTI、类型特性)

Defined in header<type_traits>

Defined in header<utility>

Defined in header<initializer_list>

Defined in header<iterator>

Defined in namespace std

Defined in header <array>

Defined in header <deque>

Defined in header <forward_list>

Defined in header <iterator>

Defined in header <list>

Defined in header <map>

Defined in header <regex>

Defined in header <set>

Defined in header <span>

Defined in header <string>

Defined in header <string_view>

Defined in header <unordered_map>

Defined in header <unordered_set>

Defined in header <vector>

Defined in namespace std

 

C++17新特性

关键字

含义变化或者新增含义关键字(meaning changed or new meaning added)

类型支持(基本类型、RTTI、类型特性)

Defined in header<type_traits>

Defined in header<utility>

Defined in header<tuple>

Defined in header<optional>

Defined in header<variant>

Defined in header<any>

Defined in header<charconv>

Defined in header<initializer_list>

容器库

Defined in header<map>

Defined in header<unordered_map>

Defined in header <array>

Defined in header <deque>

Defined in header <forward_list>

Defined in header <iterator>

Defined in header <list>

Defined in header <map>

Defined in header <regex>

Defined in header <set>

Defined in header <span>

Defined in header <string>

Defined in header <string_view>

Defined in header <unordered_map>

Defined in header <unordered_set>

Defined in header <vector>

Defined in namespace std

 

C++20新特性

关键字

新增关键字

含义变化或者新增含义关键字(meaning changed or new meaning added)

类型支持(基本类型、RTTI、类型特性)

Defined in header<type_traits>

协程支持

Defined in header<coroutine>

三路比较

Defined in header<compare>

Defined in header<concepts>

Defined in header<utility>

Defined in header<format>

Defined in header<memory>

Defined in header<memory_resource>

Concepts library(概念库)

Defined in header<concepts>

动态内存管理

Defined in header<memory>

日期和时间工具

Defined in header<chrono>

字符串

Defined in header<string>

Defined in header<string_view>

Defined in header<cuchar>

容器库

Defined in header<array>

Defined in header<vector>

Defined in header<map>

Defined in header<unordered_map>

Defined in header<span>

Defined in namespace std

Defined in namespace std::ranges

Defined in namespace std

Defined in header

Defined in namespace std

Defined in header

Defined in header <array>

Defined in header <deque>

Defined in header <forward_list>

Defined in header <iterator>

Defined in header <list>

Defined in header <map>

Defined in header <regex>

Defined in header <set>

Defined in header <span>

Defined in header <string>

Defined in header <string_view>

Defined in header <unordered_map>

Defined in header <unordered_set>

Defined in header <vector>

Defined in namespace std

Defined in header <ranges>

Defined in header <iterator>

Defined in namespace std::ranges

 

C++23新特性

类型支持(基本类型、RTTI、类型特性)

Defined in header<type_traits>

Defined in header<utility>

Defined in header<stacktrace>

动态内存管理

Defined in header<memory>

字符串

Defined in header<string>

Defined in header<string_view>

 

=============== End

 

posted @ 2021-09-20 22:23  lsgxeva  阅读(2737)  评论(0编辑  收藏  举报