Skip to content

Commit 789ba18

Browse files
authored
Simplify is_iterable write overloads (#34)
1 parent 4eac75a commit 789ba18

2 files changed

Lines changed: 4 additions & 30 deletions

File tree

include/hexi/binary_stream.h

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -289,21 +289,8 @@ class binary_stream final {
289289
return *this;
290290
}
291291

292-
template<std::ranges::contiguous_range range>
293-
requires pod<typename range::value_type>
294-
binary_stream& operator <<(const range& data) requires writeable<buf_type> {
295-
const auto write_size = data.size() * sizeof(typename range::value_type);
296-
write(data.data(), write_size);
297-
return *this;
298-
}
299-
300-
template<is_iterable T>
301-
requires (!pod<typename T::value_type> || !std::ranges::contiguous_range<T>)
302-
binary_stream& operator<<(T& data) requires writeable<buf_type> {
303-
for(auto& element : data) {
304-
*this << element;
305-
}
306-
292+
binary_stream& operator <<(const is_iterable auto& data) requires writeable<buf_type> {
293+
write_container(data);
307294
return *this;
308295
}
309296

include/hexi/pmc/binary_stream_writer.h

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -153,21 +153,8 @@ class binary_stream_writer : virtual public stream_base {
153153
return *this;
154154
}
155155

156-
template<std::ranges::contiguous_range range>
157-
requires pod<typename range::value_type>
158-
binary_stream_writer& operator <<(const range& data) {
159-
const auto write_size = data.size() * sizeof(typename range::value_type);
160-
write(data.data(), write_size);
161-
return *this;
162-
}
163-
164-
template<is_iterable T>
165-
requires (!pod<typename T::value_type> || !std::ranges::contiguous_range<T>)
166-
binary_stream_writer& operator<<(T& data) {
167-
for(auto& element : data) {
168-
*this << element;
169-
}
170-
156+
binary_stream_writer& operator <<(const is_iterable auto& data) {
157+
write_container(data);
171158
return *this;
172159
}
173160

0 commit comments

Comments
 (0)