ExperimentalFeatures.rst 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. =====================
  2. Experimental Features
  3. =====================
  4. .. contents::
  5. :local:
  6. .. _experimental features:
  7. Overview
  8. ========
  9. Libc++ implements technical specifications (TSes) and ships them as experimental
  10. features that users are free to try out. The goal is to allow getting feedback
  11. on those experimental features.
  12. However, libc++ does not provide the same guarantees about those features as
  13. it does for the rest of the library. In particular, no ABI or API stability
  14. is guaranteed, and experimental features are deprecated once the non-experimental
  15. equivalent has shipped in the library. This document outlines the details of
  16. that process.
  17. Background
  18. ==========
  19. The "end game" of a Technical Specification (TS) is to have the features in
  20. there added to a future version of the C++ Standard. When this happens, the TS
  21. can be retired. Sometimes, only part of at TS is added to the standard, and
  22. the rest of the features may be incorporated into the next version of the TS.
  23. Adoption leaves library implementors with two implementations of a feature,
  24. one in namespace ``std``, and the other in namespace ``std::experimental``.
  25. The first one will continue to evolve (via issues and papers), while the other
  26. will not. Gradually they will diverge. It's not good for users to have two
  27. (subtly) different implementations of the same functionality in the same library.
  28. Design
  29. ======
  30. When a feature is adopted into the main standard, we implement it in namespace
  31. ``std``. Once that implementation is complete, we then create a deprecation
  32. warning for the corresponding experimental feature warning users to move off
  33. of it and to the now-standardized feature.
  34. These deprecation warnings are guarded by a macro of the form
  35. ``_LIBCPP_NO_EXPERIMENTAL_DEPRECATION_WARNING_<FEATURE>``, which
  36. can be defined by users to disable the deprecation warning. Whenever
  37. possible, deprecation warnings are put on a per-declaration basis
  38. using the ``[[deprecated]]`` attribute, which also allows disabling
  39. the warnings using ``-Wno-deprecated-declarations``.
  40. After **2 releases** of LLVM, the experimental feature is removed completely
  41. (and the deprecation notice too). Using the experimental feature simply becomes
  42. an error. Furthermore, when an experimental header becomes empty due to the
  43. removal of the corresponding experimental feature, the header is removed.
  44. Keeping the header around creates incorrect assumptions from users and breaks
  45. ``__has_include``.
  46. Status of TSes
  47. ==============
  48. Library Fundamentals TS `V1 <https://wg21.link/N4480>`__ and `V2 <https://wg21.link/N4617>`__
  49. ---------------------------------------------------------------------------------------------
  50. Most (but not all) of the features of the LFTS were accepted into C++17.
  51. +---------+-------------------------------------------------------+--------------------+------------------------------------------+-------------------------+
  52. | Section | Feature | Shipped in ``std`` | To be removed from ``std::experimental`` | Notes |
  53. +=========+=======================================================+====================+==========================================+=========================+
  54. | 2.1 | ``uses_allocator construction`` | 5.0 | 7.0 | |
  55. +---------+-------------------------------------------------------+--------------------+------------------------------------------+-------------------------+
  56. | 3.1.2 | ``erased_type`` | | n/a | Not part of C++17 |
  57. +---------+-------------------------------------------------------+--------------------+------------------------------------------+-------------------------+
  58. | 3.2.1 | ``tuple_size_v`` | 5.0 | 7.0 | Removed |
  59. +---------+-------------------------------------------------------+--------------------+------------------------------------------+-------------------------+
  60. | 3.2.2 | ``apply`` | 5.0 | 7.0 | Removed |
  61. +---------+-------------------------------------------------------+--------------------+------------------------------------------+-------------------------+
  62. | 3.3.1 | All of the ``_v`` traits in ``<type_traits>`` | 5.0 | 7.0 | Removed |
  63. +---------+-------------------------------------------------------+--------------------+------------------------------------------+-------------------------+
  64. | 3.3.2 | ``invocation_type`` and ``raw_invocation_type`` | | n/a | Not part of C++17 |
  65. +---------+-------------------------------------------------------+--------------------+------------------------------------------+-------------------------+
  66. | 3.3.3 | Logical operator traits | 5.0 | 7.0 | Removed |
  67. +---------+-------------------------------------------------------+--------------------+------------------------------------------+-------------------------+
  68. | 3.3.3 | Detection Idiom | 5.0 | | Only partially in C++17 |
  69. +---------+-------------------------------------------------------+--------------------+------------------------------------------+-------------------------+
  70. | 3.4.1 | All of the ``_v`` traits in ``<ratio>`` | 5.0 | 7.0 | Removed |
  71. +---------+-------------------------------------------------------+--------------------+------------------------------------------+-------------------------+
  72. | 3.5.1 | All of the ``_v`` traits in ``<chrono>`` | 5.0 | 7.0 | Removed |
  73. +---------+-------------------------------------------------------+--------------------+------------------------------------------+-------------------------+
  74. | 3.6.1 | All of the ``_v`` traits in ``<system_error>`` | 5.0 | 7.0 | Removed |
  75. +---------+-------------------------------------------------------+--------------------+------------------------------------------+-------------------------+
  76. | 3.7 | ``propagate_const`` | | n/a | Not part of C++17 |
  77. +---------+-------------------------------------------------------+--------------------+------------------------------------------+-------------------------+
  78. | 4.2 | Enhancements to ``function`` | Not yet | | |
  79. +---------+-------------------------------------------------------+--------------------+------------------------------------------+-------------------------+
  80. | 4.3 | searchers | 7.0 | 9.0 | |
  81. +---------+-------------------------------------------------------+--------------------+------------------------------------------+-------------------------+
  82. | 5 | optional | 5.0 | 7.0 | Removed |
  83. +---------+-------------------------------------------------------+--------------------+------------------------------------------+-------------------------+
  84. | 6 | ``any`` | 5.0 | 7.0 | Removed |
  85. +---------+-------------------------------------------------------+--------------------+------------------------------------------+-------------------------+
  86. | 7 | ``string_view`` | 5.0 | 7.0 | Removed |
  87. +---------+-------------------------------------------------------+--------------------+------------------------------------------+-------------------------+
  88. | 8.2.1 | ``shared_ptr`` enhancements | Not yet | Never added | |
  89. +---------+-------------------------------------------------------+--------------------+------------------------------------------+-------------------------+
  90. | 8.2.2 | ``weak_ptr`` enhancements | Not yet | Never added | |
  91. +---------+-------------------------------------------------------+--------------------+------------------------------------------+-------------------------+
  92. | 8.5 | ``memory_resource`` | Not yet | | |
  93. +---------+-------------------------------------------------------+--------------------+------------------------------------------+-------------------------+
  94. | 8.6 | ``polymorphic_allocator`` | Not yet | | |
  95. +---------+-------------------------------------------------------+--------------------+------------------------------------------+-------------------------+
  96. | 8.7 | ``resource_adaptor`` | | n/a | Not part of C++17 |
  97. +---------+-------------------------------------------------------+--------------------+------------------------------------------+-------------------------+
  98. | 8.8 | Access to program-wide ``memory_resource`` objects | Not yet | | |
  99. +---------+-------------------------------------------------------+--------------------+------------------------------------------+-------------------------+
  100. | 8.9 | Pool resource classes | Not yet | | |
  101. +---------+-------------------------------------------------------+--------------------+------------------------------------------+-------------------------+
  102. | 8.10 | ``monotonic_buffer_resource`` | Not yet | | |
  103. +---------+-------------------------------------------------------+--------------------+------------------------------------------+-------------------------+
  104. | 8.11 | Alias templates using polymorphic memory resources | Not yet | | |
  105. +---------+-------------------------------------------------------+--------------------+------------------------------------------+-------------------------+
  106. | 8.12 | Non-owning pointers | | n/a | Not part of C++17 |
  107. +---------+-------------------------------------------------------+--------------------+------------------------------------------+-------------------------+
  108. | 11.2 | ``promise`` | | n/a | Not part of C++17 |
  109. +---------+-------------------------------------------------------+--------------------+------------------------------------------+-------------------------+
  110. | 11.3 | ``packaged_task`` | | n/a | Not part of C++17 |
  111. +---------+-------------------------------------------------------+--------------------+------------------------------------------+-------------------------+
  112. | 12.2 | ``search`` | 7.0 | 9.0 | |
  113. +---------+-------------------------------------------------------+--------------------+------------------------------------------+-------------------------+
  114. | 12.3 | ``sample`` | 5.0 | 7.0 | Removed |
  115. +---------+-------------------------------------------------------+--------------------+------------------------------------------+-------------------------+
  116. | 12.4 | ``shuffle`` | | | Not part of C++17 |
  117. +---------+-------------------------------------------------------+--------------------+------------------------------------------+-------------------------+
  118. | 13.1 | ``gcd`` and ``lcm`` | 5.0 | 7.0 | Removed |
  119. +---------+-------------------------------------------------------+--------------------+------------------------------------------+-------------------------+
  120. | 13.2 | Random number generation | | | Not part of C++17 |
  121. +---------+-------------------------------------------------------+--------------------+------------------------------------------+-------------------------+
  122. | 14 | Reflection Library | | | Not part of C++17 |
  123. +---------+-------------------------------------------------------+--------------------+------------------------------------------+-------------------------+
  124. `FileSystem TS <https://wg21.link/N4100>`__
  125. -------------------------------------------
  126. The FileSystem TS was accepted (in totality) for C++17.
  127. The FileSystem TS implementation was shipped in namespace ``std`` in LLVM 7.0, and will be removed in LLVM 11.0 (due to the lack of deprecation warnings before LLVM 9.0).
  128. Parallelism TS `V1 <https://wg21.link/N4507>`__ and `V2 <https://wg21.link/N4706>`__
  129. ------------------------------------------------------------------------------------
  130. Some (most) of the Parallelism TS was accepted for C++17.
  131. We have not yet shipped an implementation of the Parallelism TS.
  132. `Coroutines TS <https://wg21.link/N4680>`__
  133. -------------------------------------------
  134. The Coroutines TS is not yet part of a shipping standard.
  135. We are shipping (as of v5.0) an implementation of the Coroutines TS in namespace ``std::experimental``.
  136. `Networking TS <https://wg21.link/N4656>`__
  137. -------------------------------------------
  138. The Networking TS is not yet part of a shipping standard.
  139. We have not yet shipped an implementation of the Networking TS.
  140. `Ranges TS <https://wg21.link/N4685>`__
  141. ---------------------------------------
  142. The Ranges TS is not yet part of a shipping standard.
  143. We have not yet shipped an implementation of the Ranges TS.
  144. `Concepts TS <https://wg21.link/N4641>`__
  145. -----------------------------------------
  146. The Concepts TS is not yet part of a shipping standard, but it has been adopted into the C++20 working draft.
  147. We have not yet shipped an implementation of the Concepts TS.
  148. `Concurrency TS <https://wg21.link/P0159>`__
  149. --------------------------------------------
  150. The Concurrency TS was adopted in Kona (2015).
  151. None of the Concurrency TS was accepted for C++17.
  152. We have not yet shipped an implementation of the Concurrency TS.
  153. .. +---------+-------------------------------------------------------+--------------------+------------------------------------------+-------------------------+
  154. .. | Section | Feature | Shipped in ``std`` | To be removed from ``std::experimental`` | Notes |
  155. .. +=========+=======================================================+====================+==========================================+=========================+
  156. .. | 2.3 | class template ``future`` | | | |
  157. .. +---------+-------------------------------------------------------+--------------------+------------------------------------------+-------------------------+
  158. .. | 2.4 | class template ``shared_future`` | | | |
  159. .. +---------+-------------------------------------------------------+--------------------+------------------------------------------+-------------------------+
  160. .. | 2.5 | class template ``promise`` | | | Only using ``future`` |
  161. .. +---------+-------------------------------------------------------+--------------------+------------------------------------------+-------------------------+
  162. .. | 2.6 | class template ``packaged_task`` | | | Only using ``future`` |
  163. .. +---------+-------------------------------------------------------+--------------------+------------------------------------------+-------------------------+
  164. .. | 2.7 | function template ``when_all`` | | | Not part of C++17 |
  165. .. +---------+-------------------------------------------------------+--------------------+------------------------------------------+-------------------------+
  166. .. | 2.8 | class template ``when_any_result`` | | | Not part of C++17 |
  167. .. +---------+-------------------------------------------------------+--------------------+------------------------------------------+-------------------------+
  168. .. | 2.9 | function template ``when_any`` | | | Not part of C++17 |
  169. .. +---------+-------------------------------------------------------+--------------------+------------------------------------------+-------------------------+
  170. .. | 2.10 | function template ``make_ready_future`` | | | Not part of C++17 |
  171. .. +---------+-------------------------------------------------------+--------------------+------------------------------------------+-------------------------+
  172. .. | 2.11 | function template ``make_exeptional_future`` | | | Not part of C++17 |
  173. .. +---------+-------------------------------------------------------+--------------------+------------------------------------------+-------------------------+
  174. .. | 3 | ``latches`` and ``barriers`` | | | Not part of C++17 |
  175. .. +---------+-------------------------------------------------------+--------------------+------------------------------------------+-------------------------+
  176. .. | 4 | Atomic Smart Pointers | | | Adopted for C++20 |
  177. .. +---------+-------------------------------------------------------+--------------------+------------------------------------------+-------------------------+