pw_polyfill: Remove C++11 and C11 polyfills
C++11 is no longer supported by Pigweed.
Change-Id: If73145fee988d2b26d44230233a79ff7bc0327b5
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/77549
Reviewed-by: Alexei Frolov <frolv@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
Commit-Queue: Wyatt Hepler <hepler@google.com>
Pigweed-Auto-Submit: Wyatt Hepler <hepler@google.com>
diff --git a/pw_polyfill/BUILD.bazel b/pw_polyfill/BUILD.bazel
index 0df04db..6612c53 100644
--- a/pw_polyfill/BUILD.bazel
+++ b/pw_polyfill/BUILD.bazel
@@ -26,19 +26,15 @@
cc_toolchain_import(
name = "toolchain_polyfill_overrides",
hdrs = [
- "public_overrides/assert.h",
"public_overrides/bit",
"public_overrides/cstddef",
"public_overrides/iterator",
"public_overrides/type_traits",
- "public_overrides/utility",
- "standard_library_public/pw_polyfill/standard_library/assert.h",
"standard_library_public/pw_polyfill/standard_library/bit.h",
"standard_library_public/pw_polyfill/standard_library/cstddef.h",
"standard_library_public/pw_polyfill/standard_library/iterator.h",
"standard_library_public/pw_polyfill/standard_library/namespace.h",
"standard_library_public/pw_polyfill/standard_library/type_traits.h",
- "standard_library_public/pw_polyfill/standard_library/utility.h",
],
includes = [
"public",
@@ -60,12 +56,10 @@
pw_cc_library(
name = "overrides",
hdrs = [
- "public_overrides/assert.h",
"public_overrides/bit",
"public_overrides/cstddef",
"public_overrides/iterator",
"public_overrides/type_traits",
- "public_overrides/utility",
],
includes = ["public_overrides"],
deps = [":standard_library"],
@@ -74,13 +68,11 @@
pw_cc_library(
name = "standard_library",
hdrs = [
- "standard_library_public/pw_polyfill/standard_library/assert.h",
"standard_library_public/pw_polyfill/standard_library/bit.h",
"standard_library_public/pw_polyfill/standard_library/cstddef.h",
"standard_library_public/pw_polyfill/standard_library/iterator.h",
"standard_library_public/pw_polyfill/standard_library/namespace.h",
"standard_library_public/pw_polyfill/standard_library/type_traits.h",
- "standard_library_public/pw_polyfill/standard_library/utility.h",
],
includes = ["standard_library_public"],
visibility = ["//visibility:private"],
diff --git a/pw_polyfill/BUILD.gn b/pw_polyfill/BUILD.gn
index 7c8a783..59c0bd4 100644
--- a/pw_polyfill/BUILD.gn
+++ b/pw_polyfill/BUILD.gn
@@ -46,12 +46,10 @@
"$dir_pw_span:polyfill",
]
inputs = [
- "public_overrides/assert.h",
"public_overrides/bit",
"public_overrides/cstddef",
"public_overrides/iterator",
"public_overrides/type_traits",
- "public_overrides/utility",
]
}
@@ -63,13 +61,11 @@
public_configs = [ ":standard_library_public" ]
remove_public_deps = [ "*" ]
public = [
- "standard_library_public/pw_polyfill/standard_library/assert.h",
"standard_library_public/pw_polyfill/standard_library/bit.h",
"standard_library_public/pw_polyfill/standard_library/cstddef.h",
"standard_library_public/pw_polyfill/standard_library/iterator.h",
"standard_library_public/pw_polyfill/standard_library/namespace.h",
"standard_library_public/pw_polyfill/standard_library/type_traits.h",
- "standard_library_public/pw_polyfill/standard_library/utility.h",
]
visibility = [
":overrides",
diff --git a/pw_polyfill/docs.rst b/pw_polyfill/docs.rst
index bcf160a..df26e7e 100644
--- a/pw_polyfill/docs.rst
+++ b/pw_polyfill/docs.rst
@@ -35,10 +35,8 @@
<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> \*_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) static_assert with no message full __cpp_static_assert
+<type_traits> std::bool_constant full __cpp_lib_bool_constant
+<type_traits> std::negation, etc. full __cpp_lib_logical_traits
================== ================================ =============================== ========================================
----------------------------------------------------
diff --git a/pw_polyfill/public_overrides/assert.h b/pw_polyfill/public_overrides/assert.h
deleted file mode 100644
index b2f07e5..0000000
--- a/pw_polyfill/public_overrides/assert.h
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright 2020 The Pigweed Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-// https://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-#pragma once
-
-#include_next <assert.h>
-
-#include "pw_polyfill/standard_library/assert.h"
diff --git a/pw_polyfill/public_overrides/utility b/pw_polyfill/public_overrides/utility
deleted file mode 100644
index 8d22206..0000000
--- a/pw_polyfill/public_overrides/utility
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright 2020 The Pigweed Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-// https://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-#pragma once
-
-#include_next <utility>
-
-#include "pw_polyfill/standard_library/utility.h"
diff --git a/pw_polyfill/standard_library_public/pw_polyfill/standard_library/assert.h b/pw_polyfill/standard_library_public/pw_polyfill/standard_library/assert.h
deleted file mode 100644
index 30f10f6..0000000
--- a/pw_polyfill/standard_library_public/pw_polyfill/standard_library/assert.h
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright 2020 The Pigweed Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-// https://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-#pragma once
-
-#include <assert.h>
-
-// In C11, assert.h should define static_assert as _Static_assert.
-#if !defined(__cplusplus) && !defined(static_assert)
-
-#if __STDC_VERSION__ >= 201112L
-#define static_assert _Static_assert
-#else // _Static_assert requires C11.
-#define static_assert(...)
-#endif // __STDC_VERSION__ >= 201112L
-
-#endif // !defined(__cplusplus) && !defined(static_assert)
diff --git a/pw_polyfill/standard_library_public/pw_polyfill/standard_library/type_traits.h b/pw_polyfill/standard_library_public/pw_polyfill/standard_library/type_traits.h
index f13130e..2cd602b 100644
--- a/pw_polyfill/standard_library_public/pw_polyfill/standard_library/type_traits.h
+++ b/pw_polyfill/standard_library_public/pw_polyfill/standard_library/type_traits.h
@@ -19,52 +19,6 @@
_PW_POLYFILL_BEGIN_NAMESPACE_STD
-// Defines std:foo_t aliases for typename foo::type. This is a small subset of
-// <type_traits> which may be expanded as needed.
-#ifndef __cpp_lib_transformation_trait_aliases
-#define __cpp_lib_transformation_trait_aliases 201304L
-
-template <decltype(sizeof(int)) kLen, decltype(sizeof(int)) kAlign>
-using aligned_storage_t = typename aligned_storage<kLen, kAlign>::type;
-
-template <typename... T>
-using common_type_t = typename common_type<T...>::type;
-
-template <bool kBool, typename T, typename F>
-using conditional_t = typename conditional<kBool, T, F>::type;
-
-template <typename T>
-using decay_t = typename decay<T>::type;
-
-template <bool kBool, typename T = void>
-using enable_if_t = typename enable_if<kBool, T>::type;
-
-template <typename T>
-using make_signed_t = typename make_signed<T>::type;
-
-template <typename T>
-using make_unsigned_t = typename make_unsigned<T>::type;
-
-template <typename T>
-using remove_cv_t = typename remove_cv<T>::type;
-
-template <typename T>
-using remove_pointer_t = typename remove_pointer<T>::type;
-
-template <typename T>
-using remove_reference_t = typename remove_reference<T>::type;
-
-#endif // __cpp_lib_transformation_trait_aliases
-
-#ifndef __cpp_lib_is_null_pointer
-#define __cpp_lib_is_null_pointer 201309L
-
-template <typename T>
-struct is_null_pointer : std::is_same<decltype(nullptr), std::remove_cv_t<T>> {
-};
-
-#endif // __cpp_lib_is_null_pointer
-
#ifndef __cpp_lib_bool_constant
#define __cpp_lib_bool_constant 201505L
template <bool kValue>
diff --git a/pw_polyfill/standard_library_public/pw_polyfill/standard_library/utility.h b/pw_polyfill/standard_library_public/pw_polyfill/standard_library/utility.h
deleted file mode 100644
index f81f948..0000000
--- a/pw_polyfill/standard_library_public/pw_polyfill/standard_library/utility.h
+++ /dev/null
@@ -1,57 +0,0 @@
-// Copyright 2020 The Pigweed Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-// https://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-#pragma once
-
-#include <utility>
-
-#include "pw_polyfill/standard_library/namespace.h"
-
-#ifndef __cpp_lib_integer_sequence
-#define __cpp_lib_integer_sequence 201304L
-
-_PW_POLYFILL_BEGIN_NAMESPACE_STD
-
-template <typename T, T... kSequence>
-struct integer_sequence {
- static constexpr size_t size() noexcept { return sizeof...(kSequence); }
-};
-
-namespace impl {
-
-// In the absence of a compiler builtin for this, have MakeSequence expand
-// recursively to enumerate all indices up to count.
-template <size_t kCount, typename T, T... kSequence>
-struct MakeSequence : MakeSequence<kCount - 1, T, kCount - 1, kSequence...> {};
-
-template <typename T, T... kSequence>
-struct MakeSequence<0, T, kSequence...>
- : std::integer_sequence<T, kSequence...> {};
-
-} // namespace impl
-
-template <size_t... kSequence>
-using index_sequence = integer_sequence<size_t, kSequence...>;
-
-template <typename T, T kCount>
-using make_integer_sequence = impl::MakeSequence<kCount, T>;
-
-template <size_t kCount>
-using make_index_sequence = make_integer_sequence<size_t, kCount>;
-
-template <typename... T>
-using index_sequence_for = make_index_sequence<sizeof...(T)>;
-
-_PW_POLYFILL_END_NAMESPACE_STD
-
-#endif // __cpp_lib_integer_sequence
diff --git a/pw_polyfill/test.cc b/pw_polyfill/test.cc
index 5b32064..b761d4e 100644
--- a/pw_polyfill/test.cc
+++ b/pw_polyfill/test.cc
@@ -21,7 +21,6 @@
#include "pw_polyfill/standard_library/cstddef.h"
#include "pw_polyfill/standard_library/iterator.h"
#include "pw_polyfill/standard_library/type_traits.h"
-#include "pw_polyfill/standard_library/utility.h"
namespace pw {
namespace polyfill {
@@ -141,18 +140,7 @@
"Alias must be defined");
}
-TEST(Utility, IntegerSequence) {
- static_assert(std::integer_sequence<int>::size() == 0,
- "zero-length integer_sequence");
- static_assert(std::integer_sequence<int, 9, 8, 7>::size() == 3,
- "integer_sequence with size 3");
- static_assert(std::make_index_sequence<1>::size() == 1,
- "integer_sequence with size 1");
- static_assert(std::make_index_sequence<123>::size() == 123,
- "integer_sequence with size 1");
-}
-
-TEST(Utility, LogicalTraits) {
+TEST(TypeTraits, LogicalTraits) {
static_assert(std::conjunction<std::true_type, std::true_type>::value,
"conjunction should be true");
static_assert(!std::conjunction<std::true_type, std::false_type>::value,