Skip to content

Commit

Permalink
pw_polyfill: Remove implicit polyfills for C++14
Browse files Browse the repository at this point in the history
Remove implicit <cstddef>, <iterator>, and <type_traits> polyfills.
The polyfill headers can be depended on explicitly if needed.

Bug: 602
Change-Id: I6f45a2cf7d275ac07d6cf7f0fd7c55cce8ac0b63
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/96443
Reviewed-by: Armando Montanez <amontanez@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
Pigweed-Auto-Submit: Wyatt Hepler <hepler@google.com>
  • Loading branch information
255 authored and CQ Bot Account committed Jun 2, 2022
1 parent 75a269c commit 24d03e5
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 28 deletions.
3 changes: 0 additions & 3 deletions pw_polyfill/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,7 @@ pw_cc_library(
name = "overrides",
deps = [
":bit",
":cstddef",
":iterator",
":span",
":type_traits",
],
)

Expand Down
10 changes: 6 additions & 4 deletions pw_polyfill/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@ config("overrides_config") {
group("overrides") {
public_deps = [
":bit",
":cstddef",
":iterator",
":span",
":type_traits",
]
}

Expand Down Expand Up @@ -123,7 +120,12 @@ pw_test_group("tests") {
}

pw_test("test") {
deps = [ ":pw_polyfill" ]
deps = [
":cstddef",
":iterator",
":pw_polyfill",
":type_traits",
]
sources = [ "test.cc" ]
}

Expand Down
3 changes: 0 additions & 3 deletions pw_polyfill/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ endif()
pw_add_module_library(pw_polyfill.overrides
PUBLIC_DEPS
pw_polyfill.bit
pw_polyfill.cstddef
pw_polyfill.iterator
pw_polyfill.span
pw_polyfill.type_traits
)
if(Zephyr_FOUND AND CONFIG_PIGWEED_POLYFILL_OVERRIDES)
zephyr_link_libraries(pw_polyfill.overrides)
Expand Down
38 changes: 20 additions & 18 deletions pw_polyfill/docs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,31 @@ provided by the standard header, so ``pw_polyfill`` is safe to use when
compiling with any standard C++14 or newer.

The wrapper headers are in ``public_overrides``. These are provided through the
``"$dir_pw_polyfill"`` libraries, which the GN build adds as a
dependency for all targets:
following libraries:

* ``$dir_pw_polyfill:bit``
* ``$dir_pw_polyfill:cstddef``
* ``$dir_pw_polyfill:iterator``
* ``$dir_pw_polyfill:span``
* ``$dir_pw_polyfill:type_traits``
* ``pw_polyfill:bit``
* ``pw_polyfill:cstddef``
* ``pw_polyfill:iterator``
* ``pw_polyfill:span``
* ``pw_polyfill:type_traits``

To apply overrides in Bazel or CMake, depend on the targets you need such as
``//pw_polyfill:span`` or ``pw_polyfill.span`` as an example.
The GN build automatically adds dependencies on the ``<bit>`` and ``<span>``
headers. To apply other overrides, add dependencies as needed. In Bazel or
CMake, overrides are not applied automatically, so depend on the targets you
need such as ``//pw_polyfill:span`` or ``pw_polyfill.span``.

Backported features
===================
================== ================================ =============================== ========================================
Header Feature Level of support Feature test macro
================== ================================ =============================== ========================================
<bit> std::endian full __cpp_lib_endian
<cstdlib> std::byte full __cpp_lib_byte
<iterator> std::data, std::size full __cpp_lib_nonmember_container_access
<type_traits> std::bool_constant full __cpp_lib_bool_constant
<type_traits> std::negation, etc. full __cpp_lib_logical_traits
================== ================================ =============================== ========================================
================== ================================ ================ ======================================== =============
Header Feature Level of support Feature test macro Implicit dep?
================== ================================ ================ ======================================== =============
<bit> std::endian full __cpp_lib_endian GN
<cstdlib> std::byte full __cpp_lib_byte ❌
<iterator> std::data, std::size full __cpp_lib_nonmember_container_access ❌
<span> std::span no std::ranges __cpp_lib_span GN
<type_traits> std::bool_constant full __cpp_lib_bool_constant ❌
<type_traits> std::negation, etc. full __cpp_lib_logical_traits ❌
================== ================================ ================ ======================================== =============

----------------------------------------------------
Adapt code to compile with different versions of C++
Expand Down

0 comments on commit 24d03e5

Please sign in to comment.