Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/Stream/Writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,23 @@ namespace OP2Utility::Stream
WriteImplementation(container.data(), container.size() * sizeof(typename T::value_type));
}

// Arbitrary container of writeable data types
// For use when the container is non-contiguous, or the element type is not trivially copyable
template<typename T>
inline
std::enable_if_t<
// The enable_if check needs to change to something like:
// is_iterable<T> && is_writeable<typename T::value_type>
// For now, we leave the old check to avoid ambiguity
!std::is_trivially_copyable<typename T::value_type>::value
>
Write(const T& container) {
// Loop over all elements and call custom serializer for type
for (const auto& element : container) {
Write(element); // Call custom serializer
}
}

// Size prefixed container data types
// Ex: Write<uint32_t>(vector); // Write 32-bit vector size followed by vector data
template<typename SizeType, typename T>
Expand Down