From af5a420607e5166aba8c43e8e1bda341e17cbd2f Mon Sep 17 00:00:00 2001 From: "Zezheng.Li" Date: Tue, 22 Aug 2023 11:06:24 +0800 Subject: [PATCH] fix sfinae --- include/ylt/struct_pack/reflection.hpp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/include/ylt/struct_pack/reflection.hpp b/include/ylt/struct_pack/reflection.hpp index 35c2fc41d0..441193c6a4 100644 --- a/include/ylt/struct_pack/reflection.hpp +++ b/include/ylt/struct_pack/reflection.hpp @@ -402,19 +402,30 @@ template } && (Type{}.size()+7)/8 == sizeof(Type); #else template - struct bitset_container_impl : std::false_type {}; + struct bitset_impl : std::false_type {}; + template - struct bitset_container_impl().size()>, + struct bitset_impl().flip()), decltype(std::declval().set()), decltype(std::declval().reset()), - decltype(std::declval().count())>> + decltype(std::declval().count()), + decltype(std::declval().size())>> : std::true_type {}; + template + constexpr bool bitset_size_checker() { + if constexpr (bitset_impl::value) { + return (T{}.size()+7)/8==sizeof(T); + } + else { + return false; + } + } + template - constexpr bool bitset = bitset_container_impl::value && sizeof(T)==(T{}.size()+7)/8; + constexpr bool bitset = bitset_impl::value && bitset_size_checker(); #endif #if __cpp_concepts >= 201907L