From a23e5b103f5b2d0c55f6766c3340341356a87d47 Mon Sep 17 00:00:00 2001 From: Arthur O'Dwyer Date: Thu, 19 Oct 2023 14:27:01 -0400 Subject: [PATCH] [hive] Eliminate bit_cast dependency I don't think it was ever correct to use std::bit_cast here. Prefer the core-language facility (reinterpret_cast), given that it does the same thing. --- include/sg14/hive.h | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/include/sg14/hive.h b/include/sg14/hive.h index f13cf6d..de13767 100644 --- a/include/sg14/hive.h +++ b/include/sg14/hive.h @@ -54,7 +54,6 @@ #include #if __cplusplus >= 202002L -#include #include #include #include @@ -178,15 +177,13 @@ class hive { NextAndPrev s_; T t_; }; - PtrOf t() { return bitcast_pointer>(std::addressof(t_)); } + PtrOf t() { return cast_pointer>(std::addressof(t_)); } ~overaligned_elt() = delete; }; template - static constexpr D bitcast_pointer(S source_pointer) { -#if __cpp_lib_bit_cast >= 201806L && __cpp_lib_to_address >= 201711L - return std::bit_cast(std::to_address(source_pointer)); -#elif __cpp_lib_to_address >= 201711L + static D cast_pointer(S source_pointer) { +#if __cpp_lib_to_address >= 201711L return reinterpret_cast(std::to_address(source_pointer)); #else return reinterpret_cast(source_pointer); // reject fancy pointer types @@ -1135,7 +1132,7 @@ class hive { size_t n = (bytes_for_group + bytes_for_elts + bytes_for_skipfield + sizeof(type) - 1) / sizeof(type); PtrOf p = std::allocator_traits>::allocate(ta, n); GroupPtr g = PtrOf(p); - ::new (bitcast_pointer(g)) group(cap); + ::new (cast_pointer(g)) group(cap); return g; } static void deallocate_group(allocator_type a, GroupPtr g) {