C++17

C++17又稱C++1z,是C++的現行標準的非正式名稱,正式名稱為"International Standard ISO/IEC Programming Language C++"。C++17旨在作為大型擴充功能,最終的投票期將於2017年結束。

目前不少著名C++編譯器已支持C++17仍未定案的草案(draft),例如最新的GCC6已支持C++ concept的C++事务型内存(Transactional Memory),Visual Studio與Clang目前都提供了modules。

新功能

  • 靜態斷言static_assert無需提供出錯信息[1]
  • 新增std::basic_string_view, 對外部字元序列或字串片斷(string-slice)的引用[2]
  • 移除 trigraphs[3][4]
  • 具有模板形式的模板(template template)参数允许使用 typename(之前仅允许使用 class)[5]
  • auto之新規定並簡化在括弧內初始化的定義[6][7]
  • 嵌套的 namespace的定義[7][8]
  • std::uncaught_exceptions 取代 std::uncaught_exception[9][10]
  • 支持UTF-8字元[10][11]
  • 变长参数模板的Folding运算[10][12]
  • std::mapstd::unordered_map增加了基于结点的插入操作[13][14]
  • 容器存取操作表示方法的统一化(Uniform container access)[14][15]
  • 连续型迭代器(Contiguous Iterators)[14][16]
  • ifswitch述句內的初始化
  • 基于boost::filesystem新增处理文件路径的std::filesystem[17]
  • 具有并行處理功能的STL 演算法[18]
  • 新增特殊數學函數[19]
  • 引进Library Fundamentals TS I中的内容[20]
  • std::variant,可作为型別安全(type-safe)的聯合所使用的容器(union container)
  • 編譯期靜態确定的 if判斷式if constexpr(expression)
  • 結構化綁定,允許auto [a, b] = getTwoReturnValues();
  • 簡化模板之建構函式,例如允許以pair(5.0, false) 取代pair<double,bool>(5.0, false)
  • 內聯式(Inline)變數,允許在標頭檔(header files)宣告變數

注釋

  1. (PDF). [2015-07-16]. (原始内容存档 (PDF)于2015-08-11).
  2. . en.cppreference.com. [2016-06-23]. (原始内容存档于2016-06-17).
  3. . 2014-05-06 [2015-07-16]. (原始内容存档于2018-07-09).
  4. IBM comment on preparing for a Trigraph-adverse future in C++17 页面存档备份,存于, IBM paper N4210, 2014-10-10. Authors: Michael Wong, Hubert Tong, Rajan Bhakta, Derek Inglis
  5. . [2015-07-16]. (原始内容存档于2015-08-11).
  6. . [2015-07-16]. (原始内容存档于2015-08-10).
  7. . [2015-07-16]. (原始内容存档于2015-03-19).
  8. . [2015-07-16]. (原始内容存档于2015-08-03).
  9. (PDF). [2015-07-16]. (原始内容 (PDF)存档于2014-11-29).
  10. . [2015-07-16]. (原始内容存档于2015-04-27).
  11. . [2015-07-16]. (原始内容存档于2015-10-28).
  12. . [2015-07-16]. (原始内容存档于2015-04-04).
  13. . [2015-07-16]. (原始内容存档于2015-04-27).
  14. . [2015-07-16]. (原始内容存档于2014-11-29).
  15. (PDF). [2015-07-16]. (原始内容存档 (PDF)于2015-03-09).
  16. . [2015-07-16]. (原始内容存档于2014-11-29).
  17. . [2016-08-02]. (原始内容存档于2016-07-20).
  18. . [2016-08-02]. (原始内容存档于2016-04-05).
  19. (PDF). [2016-08-02]. (原始内容存档 (PDF)于2016-04-05).
  20. . [2016-08-02]. (原始内容存档于2016-04-05).

另見

This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.