From c7bbc44b54e074dddc803ba39cbcb4e1db574b11 Mon Sep 17 00:00:00 2001 From: saipubw Date: Thu, 11 Jan 2024 14:25:16 +0800 Subject: [PATCH] [struct_pack][fix] fix undef macro __has_feature (#564) --- include/ylt/struct_pack/util.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/include/ylt/struct_pack/util.h b/include/ylt/struct_pack/util.h index 834b97c2a..d2d4d9342 100644 --- a/include/ylt/struct_pack/util.h +++ b/include/ylt/struct_pack/util.h @@ -178,13 +178,16 @@ template class string_thief inline void resize(std::basic_string &raw_str, std::size_t sz) { std::string &str = *reinterpret_cast(&raw_str); -#if defined(__SANITIZE_ADDRESS__) || __has_feature(address_sanitizer) || \ +#if defined(__SANITIZE_ADDRESS__) || \ + struct_pack_has_feature(address_sanitizer) || \ (!defined(NDEBUG) && defined(_MSVC_STL_VERSION)) raw_str.resize(sz); #elif defined(__GLIBCXX__) || defined(_LIBCPP_VERSION) || \ @@ -248,7 +251,7 @@ template class vector_thief::_Mypair), template inline void resize(std::vector &raw_vec, std::size_t sz) { -#if defined(__SANITIZE_ADDRESS__) || __has_feature(address_sanitizer) +#if defined(__SANITIZE_ADDRESS__) || struct_pack_has_feature(address_sanitizer) raw_vec.resize(sz); #elif defined(__GLIBCXX__) || \ (defined(_LIBCPP_VERSION) && defined(_LIBCPP_HAS_NO_ASAN)) || \ @@ -262,9 +265,7 @@ inline void resize(std::vector &raw_vec, std::size_t sz) { } #endif -#ifndef __clang__ -#undef __has_feature -#endif +#undef struct_pack_has_feature template inline void resize(T &str, std::size_t sz) {