From c1e78aec36d37bde9180203f5799bc9f8a899cdc Mon Sep 17 00:00:00 2001 From: betty Date: Tue, 1 Aug 2023 23:10:31 +0800 Subject: [PATCH] try fix msvc --- include/ylt/struct_pack/struct_pack_impl.hpp | 41 +++++++++++--------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/include/ylt/struct_pack/struct_pack_impl.hpp b/include/ylt/struct_pack/struct_pack_impl.hpp index e91a3f8828..55f108bbe2 100644 --- a/include/ylt/struct_pack/struct_pack_impl.hpp +++ b/include/ylt/struct_pack/struct_pack_impl.hpp @@ -816,7 +816,9 @@ constexpr std::size_t alignment_impl() { } template -struct calculate_trival_obj_size; +struct calculate_trival_obj_size { + constexpr void operator()(std::size_t &total); +}; template struct calculate_padding_size_impl { @@ -877,28 +879,29 @@ constexpr std::size_t total_padding_size = []() CONSTEXPR_INLINE_LAMBDA { return sum; }(); + template -struct calculate_trival_obj_size { - constexpr void operator()(std::size_t &total) { - if constexpr (I == 0) { - total += total_padding_size

; +constexpr void calculate_trival_obj_size::operator()(std::size_t &total) { + if constexpr (I == 0) { + total += total_padding_size

; + } + if constexpr (!is_compatible_v) { + if constexpr (is_trivial_serializable::value) { + total += sizeof(T); } - if constexpr (!is_compatible_v) { - if constexpr (is_trivial_serializable::value) { - total += sizeof(T); - } - else if constexpr (is_trivial_view_v) { - total += sizeof(typename T::value_type); - } - else { - static_assert(is_trivial_serializable::value); - std::size_t offset = 0; - for_each(offset); - total += offset; - } + else if constexpr (is_trivial_view_v) { + total += sizeof(typename T::value_type); + } + else { + static_assert(is_trivial_serializable::value); + std::size_t offset = 0; + for_each(offset); + total += offset; } } -}; +} + + } // namespace align // This help function is just to improve unit test coverage. :)