Skip to content

Commit

Permalink
try fix msvc
Browse files Browse the repository at this point in the history
  • Loading branch information
poor-circle committed Aug 1, 2023
1 parent e5ed8c0 commit c1e78ae
Showing 1 changed file with 22 additions and 19 deletions.
41 changes: 22 additions & 19 deletions include/ylt/struct_pack/struct_pack_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,9 @@ constexpr std::size_t alignment_impl() {
}

template <typename P, typename T, std::size_t I>
struct calculate_trival_obj_size;
struct calculate_trival_obj_size {
constexpr void operator()(std::size_t &total);
};

template <typename P, typename T, std::size_t I>
struct calculate_padding_size_impl {
Expand Down Expand Up @@ -877,28 +879,29 @@ constexpr std::size_t total_padding_size = []() CONSTEXPR_INLINE_LAMBDA {
return sum;
}();


template <typename P, typename T, std::size_t I>
struct calculate_trival_obj_size {
constexpr void operator()(std::size_t &total) {
if constexpr (I == 0) {
total += total_padding_size<P>;
constexpr void calculate_trival_obj_size<P,T,I>::operator()(std::size_t &total) {
if constexpr (I == 0) {
total += total_padding_size<P>;
}
if constexpr (!is_compatible_v<T>) {
if constexpr (is_trivial_serializable<T>::value) {
total += sizeof(T);
}
if constexpr (!is_compatible_v<T>) {
if constexpr (is_trivial_serializable<T>::value) {
total += sizeof(T);
}
else if constexpr (is_trivial_view_v<T>) {
total += sizeof(typename T::value_type);
}
else {
static_assert(is_trivial_serializable<T, true>::value);
std::size_t offset = 0;
for_each<T, calculate_trival_obj_size>(offset);
total += offset;
}
else if constexpr (is_trivial_view_v<T>) {
total += sizeof(typename T::value_type);
}
else {
static_assert(is_trivial_serializable<T, true>::value);
std::size_t offset = 0;
for_each<T, calculate_trival_obj_size>(offset);
total += offset;
}
}
};
}


} // namespace align

// This help function is just to improve unit test coverage. :)
Expand Down

0 comments on commit c1e78ae

Please sign in to comment.