版本说明
WG21(The ISO C++ committee)有严格的时间限制,每 3 年推出一版新的标准。最新的版本信息参考 WG21 官网。每个正式标准确定前,会使用草案名(draft),比如 c++1z
、c++2a
。
各版本特性
C++ 20(C++2a)
语言特性
- 协程 coroutines
- concepts
- designated initializers
- template syntax for lambdas
- range-based for loop with initializer
- [[likely]] and [[unlikely]] attributes
- deprecate implicit capture of this
- class types in non-type template parameters
- constexpr virtual functions
- explicit(bool)
- immediate functions
- using enum
- lambda capture of parameter pack
- char8_t
- constinit
库特性
- concepts library
- synchronized buffered outputstream
- std::span
- bit operations
- math constants
- std::is_constant_evaluated
- std::make_shared supports arrays
- starts_with and ends_with on strings
- check if associative container has element
- std::bit_cast
- std::midpoint
- std::to_array
C++ 17(C++1z)
语言特性
- template argument deduction for class templates
- declaring non-type template parameters with auto
- folding expressions
- new rules for auto deduction from braced-init-list
- constexpr lambda
- lambda capture this by value
- inline variables
- nested namespaces
- structured bindings
- selection statements with initializer
- constexpr if
- utf-8 character literals
- direct-list-initialization of enums
- [[fallthrough]], [[nodiscard]], [[maybe_unused]] attributes
- __has_include
- class template argument deduction
库特性
- std::variant
- std::optional
- std::any
- std::string_view
- std::invoke
- std::apply
- std::filesystem
- std::byte
- splicing for maps and sets
- parallel algorithms
- std::sample
- std::clamp
- std::reduce
- prefix sum algorithms
- gcd and lcm
- std::not_fn
- string conversion to/from numbers
C++ 14(C++1y)
语言特性
- binary literals
- generic lambda expressions
- lambda capture initializers
- return type deduction
- decltype(auto)
- relaxing constraints on constexpr functions
- variable templates
- [[deprecated]] attribute
库特性
C++ 11(C++0x / C++1x)
语言特性
- 移动语义 move semantics
- 可变参数模板 variadic templates
- 右值引用 rvalue references
- 转发引用 forwarding references
- 初始化列表 initializer lists
- 静态断言 static assertions
- auto 自动类型推导 & 返回值占位
- lambda 表达式 lambda expressions
- 表达式类型推导 decltype
- 类型重命名 type aliases
- nullptr
- strongly-typed enums
- attributes
- constexpr
- delegating constructors
- user-defined literals
- explicit virtual overrides
- final specifier
- default functions
- deleted functions
- range-based for loops
- special member functions for move semantics
- converting constructors
- explicit conversion functions
- inline-namespaces
- non-static data member initializers
- right angle brackets
- ref-qualified member functions
- trailing return types
- noexcept specifier
- char32_t and char16_t
- raw string literals
库特性
- std::move
- std::forward
- std::thread
- std::to_string
- type traits
- smart pointers
- std::chrono
- tuples
- std::tie
- std::array
- unordered containers
- std::make_shared
- std::ref
- memory model
- std::async
- std::begin/end