Skip to content

Commit

Permalink
replaced vector.insert with std::copy to avoid issues with g++ 12 (#3625
Browse files Browse the repository at this point in the history
)
  • Loading branch information
lucafedeli88 authored Jan 17, 2023
1 parent ae7998c commit b7945ae
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Source/ablastr/utils/Serialization.H
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ namespace ablastr::utils::serialization
const auto length = static_cast<int>(val.size());

put_in(length, vec);
vec.insert(vec.end(), c_str, c_str + length);
std::copy(c_str, c_str + length, std::back_inserter(vec));
}
else
{
static_assert(std::is_trivially_copyable<T>(),
"Cannot serialize non-trivally copyable types, except std::string.");

const auto *ptr_val = reinterpret_cast<const char *>(&val);
vec.insert(vec.end(), ptr_val, ptr_val + sizeof(T));
std::copy(ptr_val, ptr_val + sizeof(T), std::back_inserter(vec));
}
}

Expand Down

0 comments on commit b7945ae

Please sign in to comment.