diff --git a/io.hpp b/io.hpp index c63fe0ff..2a0016c1 100644 --- a/io.hpp +++ b/io.hpp @@ -82,6 +82,9 @@ namespace util { template void write (const fd&, const T *restrict data, size_t count); + template + void write (const fd&, const T &data); + template void write (const fd&, const T *restrict first, const T *restrict last); diff --git a/io.ipp b/io.ipp index 84812d50..c4ff35d7 100644 --- a/io.ipp +++ b/io.ipp @@ -15,6 +15,22 @@ namespace util { write (_fd, first, first + sizeof (T) * count); } + //------------------------------------------------------------------------- + template + void + write (const fd &_fd, const T &data) + { + write (_fd, &data, 1); + } + + //------------------------------------------------------------------------- + inline void + write (const fd &_fd, const void *_data, size_t _bytes) + { + auto data = reinterpret_cast (_data); + write (_fd, data, data + _bytes); + } + //------------------------------------------------------------------------- template indented::indented (const T &_data):