blob: 5cf608e0b3b13766a92f552edb2b43e618a52256 [file] [log] [blame]
Louis Dionne4b1b70d2021-07-06 10:39:01 -04001.. _using-libcxx:
2
Eric Fiselierd720d1f2015-08-22 19:40:49 +00003============
4Using libc++
5============
6
7.. contents::
8 :local:
9
Louis Dionne4b1b70d2021-07-06 10:39:01 -040010Usually, libc++ is packaged and shipped by a vendor through some delivery vehicle
11(operating system distribution, SDK, toolchain, etc) and users don't need to do
12anything special in order to use the library.
Eric Fiselierd720d1f2015-08-22 19:40:49 +000013
Louis Dionne4b1b70d2021-07-06 10:39:01 -040014This page contains information about configuration knobs that can be used by
15users when they know libc++ is used by their toolchain, and how to use libc++
16when it is not the default library used by their toolchain.
17
18
19Using a different version of the C++ Standard
20=============================================
21
22Libc++ implements the various versions of the C++ Standard. Changing the version of
23the standard can be done by passing ``-std=c++XY`` to the compiler. Libc++ will
24automatically detect what Standard is being used and will provide functionality that
25matches that Standard in the library.
Eric Fiselierd720d1f2015-08-22 19:40:49 +000026
27.. code-block:: bash
28
Louis Dionne4b1b70d2021-07-06 10:39:01 -040029 $ clang++ -std=c++17 test.cpp
Eric Fiselierd720d1f2015-08-22 19:40:49 +000030
Louis Dionne4b1b70d2021-07-06 10:39:01 -040031.. warning::
32 Using ``-std=c++XY`` with a version of the Standard that has not been ratified yet
33 is considered unstable. Libc++ reserves the right to make breaking changes to the
34 library until the standard has been ratified.
Eric Fiselierd720d1f2015-08-22 19:40:49 +000035
Eric Fiselier02cea5e2018-07-27 03:07:09 +000036
Louis Dionne3d895a12022-07-19 10:44:06 -040037Enabling experimental C++ Library features
38==========================================
Eric Fiselierd720d1f2015-08-22 19:40:49 +000039
Louis Dionne3d895a12022-07-19 10:44:06 -040040Libc++ provides implementations of some experimental features. Experimental features
41are either Technical Specifications (TSes) or official features that were voted to
42the Standard but whose implementation is not complete or stable yet in libc++. Those
43are disabled by default because they are neither API nor ABI stable. However, the
Louis Dionneeb796712022-07-20 10:42:04 -040044``-fexperimental-library`` compiler flag can be defined to turn those features on.
Eric Fiselierfa43a5c2016-05-03 22:32:08 +000045
46.. warning::
Louis Dionneeb796712022-07-20 10:42:04 -040047 Experimental libraries are experimental.
Louis Dionne3d895a12022-07-19 10:44:06 -040048 * The contents of the ``<experimental/...>`` headers and the associated static
Eric Fiselierfa43a5c2016-05-03 22:32:08 +000049 library will not remain compatible between versions.
50 * No guarantees of API or ABI stability are provided.
Louis Dionne4b1b70d2021-07-06 10:39:01 -040051 * When the standardized version of an experimental feature is implemented,
Louis Dionne37677132019-06-11 14:48:40 +000052 the experimental feature is removed two releases after the non-experimental
53 version has shipped. The full policy is explained :ref:`here <experimental features>`.
Eric Fiselierd720d1f2015-08-22 19:40:49 +000054
Louis Dionneeb796712022-07-20 10:42:04 -040055.. note::
56 On compilers that do not support the ``-fexperimental-library`` flag, users can
57 define the ``_LIBCPP_ENABLE_EXPERIMENTAL`` macro and manually link against the
58 appropriate static library (usually shipped as ``libc++experimental.a``) to get
59 access to experimental library features.
60
Eric Fiselierd720d1f2015-08-22 19:40:49 +000061
Louis Dionne4b1b70d2021-07-06 10:39:01 -040062Using libc++ when it is not the system default
63==============================================
64
65On systems where libc++ is provided but is not the default, Clang provides a flag
66called ``-stdlib=`` that can be used to decide which standard library is used.
67Using ``-stdlib=libc++`` will select libc++:
Eric Fiselierd720d1f2015-08-22 19:40:49 +000068
69.. code-block:: bash
70
Louis Dionne4b1b70d2021-07-06 10:39:01 -040071 $ clang++ -stdlib=libc++ test.cpp
Eric Fiselierd720d1f2015-08-22 19:40:49 +000072
Louis Dionnee4745512021-09-07 12:55:48 -040073On systems where libc++ is the library in use by default such as macOS and FreeBSD,
74this flag is not required.
Louis Dionne4b1b70d2021-07-06 10:39:01 -040075
76
77.. _alternate libcxx:
78
79Using a custom built libc++
80===========================
81
82Most compilers provide a way to disable the default behavior for finding the
83standard library and to override it with custom paths. With Clang, this can
84be done with:
Eric Fiselierd720d1f2015-08-22 19:40:49 +000085
86.. code-block:: bash
87
Louis Dionne4b1b70d2021-07-06 10:39:01 -040088 $ clang++ -nostdinc++ -nostdlib++ \
89 -isystem <install>/include/c++/v1 \
90 -L <install>/lib \
91 -Wl,-rpath,<install>/lib \
92 -lc++ \
93 test.cpp
Eric Fiselierd720d1f2015-08-22 19:40:49 +000094
Louis Dionne4b1b70d2021-07-06 10:39:01 -040095The option ``-Wl,-rpath,<install>/lib`` adds a runtime library search path,
96which causes the system's dynamic linker to look for libc++ in ``<install>/lib``
97whenever the program is loaded.
Eric Fiselierd720d1f2015-08-22 19:40:49 +000098
Louis Dionne4b1b70d2021-07-06 10:39:01 -040099GCC does not support the ``-nostdlib++`` flag, so one must use ``-nodefaultlibs``
100instead. Since that removes all the standard system libraries and not just libc++,
101the system libraries must be re-added manually. For example:
Eric Fiselierd720d1f2015-08-22 19:40:49 +0000102
103.. code-block:: bash
104
Louis Dionne4b1b70d2021-07-06 10:39:01 -0400105 $ g++ -nostdinc++ -nodefaultlibs \
106 -isystem <install>/include/c++/v1 \
107 -L <install>/lib \
108 -Wl,-rpath,<install>/lib \
109 -lc++ -lc++abi -lm -lc -lgcc_s -lgcc \
110 test.cpp
Eric Fiselier41ee4312016-01-20 01:26:30 +0000111
112
113GDB Pretty printers for libc++
Louis Dionne4b1b70d2021-07-06 10:39:01 -0400114==============================
Eric Fiselier41ee4312016-01-20 01:26:30 +0000115
Louis Dionne4b1b70d2021-07-06 10:39:01 -0400116GDB does not support pretty-printing of libc++ symbols by default. However, libc++ does
117provide pretty-printers itself. Those can be used as:
Eric Fiselier41ee4312016-01-20 01:26:30 +0000118
Louis Dionne4b1b70d2021-07-06 10:39:01 -0400119.. code-block:: bash
Eric Fiselier41ee4312016-01-20 01:26:30 +0000120
Louis Dionne4b1b70d2021-07-06 10:39:01 -0400121 $ gdb -ex "source <libcxx>/utils/gdb/libcxx/printers.py" \
122 -ex "python register_libcxx_printer_loader()" \
123 <args>
Eric Fiselierb3825302016-11-13 23:00:30 +0000124
Christopher Di Bella3e395412022-11-17 07:36:37 +0000125.. _include-what-you-use:
126
127include-what-you-use (IWYU)
128===========================
129
130libc++ provides an IWYU `mapping file <https://github.com/include-what-you-use/include-what-you-use/blob/master/docs/IWYUMappings.md>`,
131which drastically improves the accuracy of the tool when using libc++. To use the mapping file with
132IWYU, you should run the tool like so:
133
134.. code-block:: bash
135
136 $ include-what-you-use -Xiwyu /path/to/libcxx/include/libcxx.imp file.cpp
137
138If you would prefer to not use that flag, then you can replace ``/path/to/include-what-you-use/share/libcxx.imp```
139file with the libc++-provided ``libcxx.imp`` file.
Eric Fiselierb3825302016-11-13 23:00:30 +0000140
Louis Dionne6e8eb552022-03-03 17:37:03 -0500141.. _assertions-mode:
142
143Enabling the "safe libc++" mode
144===============================
145
146Libc++ contains a number of assertions whose goal is to catch undefined behavior in the
147library, usually caused by precondition violations. Those assertions do not aim to be
148exhaustive -- instead they aim to provide a good balance between safety and performance.
149In particular, these assertions do not change the complexity of algorithms. However, they
150might, in some cases, interfere with compiler optimizations.
151
152By default, these assertions are turned off. Vendors can decide to turn them on while building
153the compiled library by defining ``LIBCXX_ENABLE_ASSERTIONS=ON`` at CMake configuration time.
154When ``LIBCXX_ENABLE_ASSERTIONS`` is used, the compiled library will be built with assertions
155enabled, **and** user code will be built with assertions enabled by default. If
156``LIBCXX_ENABLE_ASSERTIONS=OFF`` at CMake configure time, the compiled library will not contain
157assertions and the default when building user code will be to have assertions disabled.
158As a user, you can consult your vendor to know whether assertions are enabled by default.
159
160Furthermore, independently of any vendor-selected default, users can always control whether
161assertions are enabled in their code by defining ``_LIBCPP_ENABLE_ASSERTIONS=0|1`` before
162including any libc++ header (we recommend passing ``-D_LIBCPP_ENABLE_ASSERTIONS=X`` to the
163compiler). Note that if the compiled library was built by the vendor without assertions,
164functions compiled inside the static or shared library won't have assertions enabled even
165if the user defines ``_LIBCPP_ENABLE_ASSERTIONS=1`` (the same is true for the inverse case
166where the static or shared library was compiled **with** assertions but the user tries to
167disable them). However, most of the code in libc++ is in the headers, so the user-selected
168value for ``_LIBCPP_ENABLE_ASSERTIONS`` (if any) will usually be respected.
169
Louis Dionnea164faa2022-07-25 13:43:47 -0400170When an assertion fails, the program is aborted through a special verbose termination function. The
171library provides a default function that prints an error message and calls ``std::abort()``. Note
172that this function is provided by the static or shared library, so it is only available when deploying
Louis Dionne9a4b6542022-08-04 15:25:48 -0400173to a platform where the compiled library is sufficiently recent. On older platforms, the program will
174terminate in an unspecified unsuccessful manner, but the quality of diagnostics won't be great.
175However, users can also override that function with their own, which can be useful to either provide
176custom behavior or when deploying to an older platform where the default function isn't available.
Louis Dionne6e8eb552022-03-03 17:37:03 -0500177
Louis Dionne9a4b6542022-08-04 15:25:48 -0400178Replacing the default verbose termination function is done by defining the
179``_LIBCPP_AVAILABILITY_CUSTOM_VERBOSE_ABORT_PROVIDED`` macro in all translation units of your program
180and defining the following function in exactly one translation unit:
Louis Dionne6e8eb552022-03-03 17:37:03 -0500181
182.. code-block:: cpp
183
Louis Dionnea164faa2022-07-25 13:43:47 -0400184 void __libcpp_verbose_abort(char const* format, ...)
Louis Dionne6e8eb552022-03-03 17:37:03 -0500185
186This mechanism is similar to how one can replace the default definition of ``operator new``
187and ``operator delete``. For example:
188
189.. code-block:: cpp
190
191 // In HelloWorldHandler.cpp
Louis Dionnea164faa2022-07-25 13:43:47 -0400192 #include <version> // must include any libc++ header before defining the function (C compatibility headers excluded)
Louis Dionne6e8eb552022-03-03 17:37:03 -0500193
Louis Dionnea164faa2022-07-25 13:43:47 -0400194 void std::__libcpp_verbose_abort(char const* format, ...) {
Louis Dionne400269d2022-07-25 13:19:51 -0400195 va_list list;
196 va_start(list, format);
197 std::vfprintf(stderr, format, list);
198 va_end(list);
199
Louis Dionne6e8eb552022-03-03 17:37:03 -0500200 std::abort();
201 }
202
203 // In HelloWorld.cpp
204 #include <vector>
205
206 int main() {
207 std::vector<int> v;
Louis Dionnea164faa2022-07-25 13:43:47 -0400208 int& x = v[0]; // Your termination function will be called here if _LIBCPP_ENABLE_ASSERTIONS=1
Louis Dionne6e8eb552022-03-03 17:37:03 -0500209 }
210
Louis Dionnea164faa2022-07-25 13:43:47 -0400211Also note that the verbose termination function should never return. Since assertions in libc++
212catch undefined behavior, your code will proceed with undefined behavior if your function is called
213and does return.
Louis Dionne6e8eb552022-03-03 17:37:03 -0500214
Louis Dionnea164faa2022-07-25 13:43:47 -0400215Furthermore, exceptions should not be thrown from the function. Indeed, many functions in the
216library are ``noexcept``, and any exception thrown from the termination function will result
217in ``std::terminate`` being called.
Louis Dionne6e8eb552022-03-03 17:37:03 -0500218
Eric Fiselierb3825302016-11-13 23:00:30 +0000219Libc++ Configuration Macros
220===========================
221
222Libc++ provides a number of configuration macros which can be used to enable
223or disable extended libc++ behavior, including enabling "debug mode" or
224thread safety annotations.
225
Eric Fiselierb3825302016-11-13 23:00:30 +0000226**_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS**:
227 This macro is used to enable -Wthread-safety annotations on libc++'s
Jennifer Chukwub9788092021-04-17 20:34:06 +0530228 ``std::mutex`` and ``std::lock_guard``. By default, these annotations are
Eric Fiselierb3825302016-11-13 23:00:30 +0000229 disabled and must be manually enabled by the user.
Shoaib Meenaif36e9882016-12-05 19:40:12 +0000230
231**_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS**:
232 This macro is used to disable all visibility annotations inside libc++.
233 Defining this macro and then building libc++ with hidden visibility gives a
234 build of libc++ which does not export any symbols, which can be useful when
235 building statically for inclusion into another library.
Eric Fiselier41b686e2016-12-08 23:57:08 +0000236
Eric Fiseliera7a14ed2017-01-13 22:02:08 +0000237**_LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS**:
238 This macro disables the additional diagnostics generated by libc++ using the
239 `diagnose_if` attribute. These additional diagnostics include checks for:
240
Louis Dionne878a3a82018-12-06 21:46:17 +0000241 * Giving `set`, `map`, `multiset`, `multimap` and their `unordered_`
242 counterparts a comparator which is not const callable.
243 * Giving an unordered associative container a hasher that is not const
244 callable.
Eric Fiseliera7a14ed2017-01-13 22:02:08 +0000245
Shoaib Meenaicfd19602017-10-09 19:25:17 +0000246**_LIBCPP_NO_VCRUNTIME**:
247 Microsoft's C and C++ headers are fairly entangled, and some of their C++
248 headers are fairly hard to avoid. In particular, `vcruntime_new.h` gets pulled
249 in from a lot of other headers and provides definitions which clash with
250 libc++ headers, such as `nothrow_t` (note that `nothrow_t` is a struct, so
251 there's no way for libc++ to provide a compatible definition, since you can't
252 have multiple definitions).
253
254 By default, libc++ solves this problem by deferring to Microsoft's vcruntime
255 headers where needed. However, it may be undesirable to depend on vcruntime
256 headers, since they may not always be available in cross-compilation setups,
257 or they may clash with other headers. The `_LIBCPP_NO_VCRUNTIME` macro
258 prevents libc++ from depending on vcruntime headers. Consequently, it also
259 prevents libc++ headers from being interoperable with vcruntime headers (from
260 the aforementioned clashes), so users of this macro are promising to not
261 attempt to combine libc++ headers with the problematic vcruntime headers. This
262 macro also currently prevents certain `operator new`/`operator delete`
263 replacement scenarios from working, e.g. replacing `operator new` and
264 expecting a non-replaced `operator new[]` to call the replaced `operator new`.
265
Nikolas Klauserbbb13612022-09-01 12:02:58 +0200266**_LIBCPP_DISABLE_NODISCARD_EXT**:
267 This macro disables library-extensions of ``[[nodiscard]]``.
Nikolas Klauser3e7bca12022-08-19 15:41:56 +0200268 See :ref:`Extended Applications of [[nodiscard]] <nodiscard extension>` for more information.
Roman Lebedevb5959fa2018-09-22 17:54:48 +0000269
Louis Dionneded5b772019-03-12 20:10:06 +0000270**_LIBCPP_DISABLE_DEPRECATION_WARNINGS**:
271 This macro disables warnings when using deprecated components. For example,
272 using `std::auto_ptr` when compiling in C++11 mode will normally trigger a
273 warning saying that `std::auto_ptr` is deprecated. If the macro is defined,
274 no warning will be emitted. By default, this macro is not defined.
Roman Lebedevb5959fa2018-09-22 17:54:48 +0000275
Eric Fiselierddd77792017-02-17 03:25:08 +0000276C++17 Specific Configuration Macros
277-----------------------------------
278**_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES**:
279 This macro is used to re-enable all the features removed in C++17. The effect
280 is equivalent to manually defining each macro listed below.
281
Eric Fiselier65d5b4c2017-02-17 03:30:25 +0000282**_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR**:
Arthur O'Dwyera6b51072021-05-24 18:36:17 -0400283 This macro is used to re-enable `auto_ptr`.
284
285**_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS**:
286 This macro is used to re-enable the `binder1st`, `binder2nd`,
287 `pointer_to_unary_function`, `pointer_to_binary_function`, `mem_fun_t`,
288 `mem_fun1_t`, `mem_fun_ref_t`, `mem_fun1_ref_t`, `const_mem_fun_t`,
289 `const_mem_fun1_t`, `const_mem_fun_ref_t`, and `const_mem_fun1_ref_t`
290 class templates, and the `bind1st`, `bind2nd`, `mem_fun`, `mem_fun_ref`,
291 and `ptr_fun` functions.
292
293**_LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE**:
294 This macro is used to re-enable the `random_shuffle` algorithm.
295
296**_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS**:
297 This macro is used to re-enable `set_unexpected`, `get_unexpected`, and
298 `unexpected`.
Roman Lebedevb5959fa2018-09-22 17:54:48 +0000299
Mark de Wever0c9fe4c2022-07-07 19:07:03 +0200300C++20 Specific Configuration Macros
301-----------------------------------
Roman Lebedevb5959fa2018-09-22 17:54:48 +0000302**_LIBCPP_DISABLE_NODISCARD_AFTER_CXX17**:
303 This macro can be used to disable diagnostics emitted from functions marked
304 ``[[nodiscard]]`` in dialects after C++17. See :ref:`Extended Applications of [[nodiscard]] <nodiscard extension>`
305 for more information.
306
Arthur O'Dwyera6b51072021-05-24 18:36:17 -0400307**_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES**:
308 This macro is used to re-enable all the features removed in C++20. The effect
309 is equivalent to manually defining each macro listed below.
310
311**_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS**:
312 This macro is used to re-enable redundant members of `allocator<T>`,
313 including `pointer`, `reference`, `rebind`, `address`, `max_size`,
314 `construct`, `destroy`, and the two-argument overload of `allocate`.
Arthur O'Dwyera6b51072021-05-24 18:36:17 -0400315
Ilya Biryukov051e6b92022-06-15 10:55:55 +0200316**_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_VOID_SPECIALIZATION**:
317 This macro is used to re-enable the library-provided specializations of
318 `allocator<void>` and `allocator<const void>`.
319 Use it in conjunction with `_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS`
320 to ensure that removed members of `allocator<void>` can be accessed.
321
Arthur O'Dwyerf5486c82021-05-25 14:34:18 -0400322**_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS**:
323 This macro is used to re-enable the `argument_type`, `result_type`,
324 `first_argument_type`, and `second_argument_type` members of class
325 templates such as `plus`, `logical_not`, `hash`, and `owner_less`.
326
Arthur O'Dwyera6b51072021-05-24 18:36:17 -0400327**_LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS**:
328 This macro is used to re-enable `not1`, `not2`, `unary_negate`,
329 and `binary_negate`.
330
331**_LIBCPP_ENABLE_CXX20_REMOVED_RAW_STORAGE_ITERATOR**:
332 This macro is used to re-enable `raw_storage_iterator`.
333
wmbatf5b33762021-07-02 17:08:36 +0000334**_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS**:
Louis Dionne4b1b70d2021-07-06 10:39:01 -0400335 This macro is used to re-enable `is_literal_type`, `is_literal_type_v`,
wmbatf5b33762021-07-02 17:08:36 +0000336 `result_of` and `result_of_t`.
Roman Lebedevb5959fa2018-09-22 17:54:48 +0000337
Louis Dionne4b1b70d2021-07-06 10:39:01 -0400338
Roman Lebedevb5959fa2018-09-22 17:54:48 +0000339Libc++ Extensions
340=================
341
342This section documents various extensions provided by libc++, how they're
343provided, and any information regarding how to use them.
344
345.. _nodiscard extension:
346
347Extended applications of ``[[nodiscard]]``
348------------------------------------------
349
350The ``[[nodiscard]]`` attribute is intended to help users find bugs where
351function return values are ignored when they shouldn't be. After C++17 the
352C++ standard has started to declared such library functions as ``[[nodiscard]]``.
353However, this application is limited and applies only to dialects after C++17.
354Users who want help diagnosing misuses of STL functions may desire a more
355liberal application of ``[[nodiscard]]``.
356
357For this reason libc++ provides an extension that does just that! The
Nikolas Klauserbbb13612022-09-01 12:02:58 +0200358extension is enabled by default and can be disabled by defining ``_LIBCPP_DISABLE_NODISCARD_EXT``.
359The extended applications of ``[[nodiscard]]`` takes two forms:
Roman Lebedevb5959fa2018-09-22 17:54:48 +0000360
3611. Backporting ``[[nodiscard]]`` to entities declared as such by the
362 standard in newer dialects, but not in the present one.
363
Arthur O'Dwyer108facb2021-04-05 14:56:03 -04003642. Extended applications of ``[[nodiscard]]``, at the library's discretion,
Roman Lebedevb5959fa2018-09-22 17:54:48 +0000365 applied to entities never declared as such by the standard.
366
Roman Lebedevb5959fa2018-09-22 17:54:48 +0000367Entities declared with ``_LIBCPP_NODISCARD_EXT``
368~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
369
370This section lists all extended applications of ``[[nodiscard]]`` to entities
371which no dialect declares as such (See the second form described above).
372
Nico Weber471b10a2019-04-03 18:13:08 +0000373* ``adjacent_find``
374* ``all_of``
375* ``any_of``
376* ``binary_search``
377* ``clamp``
378* ``count_if``
379* ``count``
380* ``equal_range``
381* ``equal``
382* ``find_end``
383* ``find_first_of``
384* ``find_if_not``
385* ``find_if``
386* ``find``
Roman Lebedevb5959fa2018-09-22 17:54:48 +0000387* ``get_temporary_buffer``
Nico Weber471b10a2019-04-03 18:13:08 +0000388* ``includes``
389* ``is_heap_until``
390* ``is_heap``
391* ``is_partitioned``
392* ``is_permutation``
393* ``is_sorted_until``
394* ``is_sorted``
395* ``lexicographical_compare``
396* ``lower_bound``
397* ``max_element``
398* ``max``
399* ``min_element``
400* ``min``
401* ``minmax_element``
402* ``minmax``
403* ``mismatch``
404* ``none_of``
405* ``remove_if``
406* ``remove``
407* ``search_n``
408* ``search``
409* ``unique``
410* ``upper_bound``
Nikolas Klauserc0745592022-11-01 20:06:11 +0100411* ``ranges::adjacent_find``
412* ``ranges::all_of``
413* ``ranges::any_of``
414* ``ranges::binary_search``
415* ``ranges::clamp``
416* ``ranges::count_if``
417* ``ranges::count``
418* ``ranges::equal_range``
419* ``ranges::equal``
420* ``ranges::find_end``
421* ``ranges::find_first_of``
422* ``ranges::find_if_not``
423* ``ranges::find_if``
424* ``ranges::find``
425* ``ranges::get_temporary_buffer``
426* ``ranges::includes``
427* ``ranges::is_heap_until``
428* ``ranges::is_heap``
429* ``ranges::is_partitioned``
430* ``ranges::is_permutation``
431* ``ranges::is_sorted_until``
432* ``ranges::is_sorted``
433* ``ranges::lexicographical_compare``
434* ``ranges::lower_bound``
435* ``ranges::max_element``
436* ``ranges::max``
437* ``ranges::min_element``
438* ``ranges::min``
439* ``ranges::minmax_element``
440* ``ranges::minmax``
441* ``ranges::mismatch``
442* ``ranges::none_of``
443* ``ranges::remove_if``
444* ``ranges::remove``
445* ``ranges::search_n``
446* ``ranges::search``
447* ``ranges::unique``
448* ``ranges::upper_bound``
Louis Dionne346587e2019-08-13 11:12:28 +0000449* ``lock_guard``'s constructors
Arthur O'Dwyer108facb2021-04-05 14:56:03 -0400450* ``as_const``
Louis Dionne1462d4d2020-05-28 14:28:38 -0400451* ``bit_cast``
Arthur O'Dwyer108facb2021-04-05 14:56:03 -0400452* ``forward``
453* ``move``
454* ``move_if_noexcept``
455* ``identity::operator()``
456* ``to_integer``
457* ``to_underlying``
Louis Dionne39948462022-06-01 15:25:14 -0400458
Louis Dionne7b125df2022-08-10 17:34:45 -0400459Extended integral type support
460------------------------------
461
462Several platforms support types that are not specified in the Standard, such as
463the 128-bit integral types ``__int128_t`` and ``__uint128_t``. As an extension,
464libc++ does a best-effort attempt to support these types like other integral
465types, by supporting them notably in:
466
467* ``<bits>``
468* ``<charconv>``
469* ``<functional>``
470* ``<type_traits>``
471* ``<format>``
472* ``<random>``
473
Louis Dionne39948462022-06-01 15:25:14 -0400474Additional types supported in random distributions
475~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
476
477The `C++ Standard <http://eel.is/c++draft/rand#req.genl-1.5>`_ mentions that instantiating several random number
478distributions with types other than ``short``, ``int``, ``long``, ``long long``, and their unsigned versions is
479undefined. As an extension, libc++ supports instantiating ``binomial_distribution``, ``discrete_distribution``,
480``geometric_distribution``, ``negative_binomial_distribution``, ``poisson_distribution``, and ``uniform_int_distribution``
481with ``int8_t``, ``__int128_t`` and their unsigned versions.
Mark de Wever367fe0f2022-07-07 20:02:07 +0200482
Mark de Wever50237422022-07-15 07:42:17 +0200483Extensions to ``<format>``
484--------------------------
485
486The exposition only type ``basic-format-string`` and its typedefs
487``format-string`` and ``wformat-string`` became ``basic_format_string``,
488``format_string``, and ``wformat_string`` in C++23. Libc++ makes these types
489available in C++20 as an extension.