pw_polyfill: Remove two language feature polyfills
This change avoids polyfilling the constinit and constexpr keywords,
which requires implicit polyfilling. Instead, this introduces a macro
that is straightforward to use and portable.
- Remove consteval and constinit language feature polyfills.
- Provide PW_CONSTINIT macro that uses the constinit keyword or compiler
attributes to guarantee constant initialization.
- Update PW_CONSTEVAL so it always marks functions constexpr.
Change-Id: I8b582b69a54717017bd30d4a33ae148f3a754095
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/50360
Pigweed-Auto-Submit: Wyatt Hepler <hepler@google.com>
Reviewed-by: Keir Mierle <keir@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
diff --git a/pw_polyfill/docs.rst b/pw_polyfill/docs.rst
index 1d35878..33b87a8 100644
--- a/pw_polyfill/docs.rst
+++ b/pw_polyfill/docs.rst
@@ -49,8 +49,6 @@
<type_traits> \*_t trait aliases partial (can expand as needed) __cpp_lib_transformation_trait_aliases
<type_traits> std::is_null_pointer full __cpp_lib_is_null_pointer
<utilty> std::integer_sequence & helpers full __cpp_lib_integer_sequence
-(language feature) consteval keyword ignored (equivalent to constexpr) __cpp_consteval
-(language feature) constinit keyword supported in clang; ignored in GCC __cpp_constinit
(language feature) static_assert with no message full __cpp_static_assert
================== ================================ ============================================ ========================================
@@ -64,6 +62,19 @@
- ``pw_polyfill/language_feature_macros.h`` -- provides macros for adapting
code to work with or without newer language features
+
+Language feature macros
+=======================
+====================== ================================ ======================================== ==========================
+Macro Feature Description Feature test macro
+====================== ================================ ======================================== ==========================
+PW_INLINE_VARIABLE inline variables inline if supported by the compiler __cpp_inline_variables
+PW_CONSTEXPR_FUNCTION relaxed constexpr function rules constexpr if relaxed rules are supported __cpp_constexpr >= 201304L
+PW_CONSTEXPR_CPP20 constexpr in C++20 constexpr if compiling for C++20 __cplusplus >= 202002L
+PW_CONSTEVAL consteval consteval if supported by the compiler __cpp_consteval
+PW_CONSTINIT constinit constinit in clang and GCC 10+ __cpp_constinit
+====================== ================================ ======================================== ==========================
+
In GN, Bazel, or CMake, depend on ``$dir_pw_polyfill``, ``//pw_polyfill``,
or ``pw_polyfill``, respectively, to access these features. In other build
systems, add ``pw_polyfill/standard_library_public`` and