跳转至

你需要知道的最常用20多个C++11新特性

1. Variadic Templates

示例:Variadic Templates

2. nullptr and nullptr_t

示例:nullptr and nullptr_t

3. Automatic Type Deduction with auto

示例:Automatic Type Deduction with auto

4. Uniform Initialization

示例:Uniform Initialization

5. initializer_list

示例:initializer_list

6. explicit for ctors taking more than one argument

示例:explicit for ctors taking more than one argument

7. range-based for statement

示例:range-based for statement

8. =default, =delete

示例:=default, =delete

9. Alias (别名) Template (template typedef)

10. template template parameter

示例:template template parameter

11. type alias

示例:type alias

12. noexcept

示例:noexcept

13. override

示例:override

14. final

示例:final

15. decltype

示例:decltype

16. lambda

示例:lambda

17. Rvalue reference

示例:Rvalue reference

18. move aware class

示例:move aware class

19. 容器-结构与分类

  • **序列式容器**包括:array(C++2.0 新引入)、vectordequelistforward_list(C++2.0 新引入)
  • **关联式容器**包括:set/multisetmap/multimap
  • 无序容器(C++2.0 新引入,更换原先 hash_xxxunordered_xxx)包括:unordered_map/unordered_multimapunordered_set/unordered_multiset

20. Hash Function

示例:Hash Function

21. tuple

示例:tuple

22. Spaces in Template Expressions

vector<list<int> > // ok in each C++ version
vector<list<int>>  // before C++11 error: ‘>>’ should be ‘> >’ within a nested template argument list, C++11 后可以正常通过

学习资料:https://www.bilibili.com/video/av51863195?from=search&seid=3610634846288253061

评论