[stdcompat] Fix bit_tests.cc for C++20
The tests against std:: used std::width (which does not exist) instead
of std::bit_width, so that now compiles. There was also a problem with
aggregate initialization which is now fixed as well.
Test: ran with -std=c++20, now compiles and passes
Change-Id: Ia8c6bdeea145e265d03aed0f6cd14de7f74a207b
Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/487601
Commit-Queue: Mark Schott <schottm@google.com>
Reviewed-by: Corey Tabaka <eieio@google.com>
Reviewed-by: Gianfranco Valentino <gevalentino@google.com>
diff --git a/sdk/lib/stdcompat/test/bit_test.cc b/sdk/lib/stdcompat/test/bit_test.cc
index 2579d6d..c3666ee 100644
--- a/sdk/lib/stdcompat/test/bit_test.cc
+++ b/sdk/lib/stdcompat/test/bit_test.cc
@@ -20,14 +20,11 @@
// Types have overriden operator& to double check that |cpp20::addressof| is used intead of &.
struct A {
- constexpr A(const A&) = default;
-
constexpr A* operator&() const { return nullptr; }
std::array<uint8_t, 8> bytes;
};
struct B {
- constexpr B(const B&) = default;
constexpr B* operator&() const { return nullptr; }
uint64_t number;
};
@@ -649,7 +646,7 @@
template <typename T>
constexpr void CheckIntPow2Alias() {
static_assert(&std::has_single_bit<T> == &cpp20::has_single_bit<T>);
- static_assert(&std::width<T> == &cpp20::width<T>);
+ static_assert(&std::bit_width<T> == &cpp20::bit_width<T>);
static_assert(&std::bit_ceil<T> == &cpp20::bit_ceil<T>);
static_assert(&std::bit_floor<T> == &cpp20::bit_floor<T>);
}