blob: 4af066fba04f9383a8459316d012920930f43488 [file] [log] [blame]
Wyatt Heplerc542a5d2020-01-15 15:43:10 -08001.. _chapter-pw-polyfill:
2
3.. default-domain:: cpp
4
5.. highlight:: sh
6
7-----------
8pw_polyfill
9-----------
10The pw_polyfill module backports C++17 features to C++11 and C++14.
11
12Compatibility
13=============
14C++11
15
16Features
17========
18
19Adapt code to compile with older versions of C++
20------------------------------------------------
21The pw_polyfill module provides features for adapting C++17 code to work when
22compiled with older C++ standards.
23
24 - ``pw_polyfill/standard.h`` -- provides a macro for checking the C++ standard
25 - ``pw_polyfill/language_features.h`` -- provides macros for adapting code to
26 work without newer language features
27 - ``pw_polyfill/standard_library/`` -- adapters for C++ standard library
28 features, such as ``std::byte``, ``std::size``/``std::data``, and type
29 traits convenience aliases
30
31In GN, Bazel, or CMake, depend on ``$dir_pw_polyfill``, ``//pw_polyfill``,
32or ``pw_polyfill``, respectively. In other build systems, add
33``pw_polyfill/standard_library_public`` and ``pw_polyfill/public_overrides`` as
34include paths.
35
36Override C++ standard library headers
37-------------------------------------
38The headers in ``public_overrides`` provide wrappers for C++ standard library
39headers, including ``<cstddef>``, ``<iterator>``, ``<type_traits>``. These are
40provided through the ``"$dir_pw_polyfill:overrides"`` library, which the GN
41build adds as a dependency for all targets. This makes some C++17 library
42features available to targets compiled with older C++ standards, without needing
43to change the code.
44
45To apply overrides in Bazel or CMake, depend on the
46``//pw_polyfill:overrides`` or ``pw_polyfill.overrides`` targets. In other build
47systems, add ``pw_polyfill/standard_library_public`` and
48``pw_polyfill/public_overrides`` as include paths.