From 47ca4a94d9f6bcf2d0be53391c34689b8c5128ee Mon Sep 17 00:00:00 2001 From: chris_kohlhoff Date: Sun, 31 Aug 2008 13:05:08 +0000 Subject: [PATCH] Use templates to handle iovec structures that have an iov_base member of type char*. --- asio/include/asio/detail/descriptor_ops.hpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/asio/include/asio/detail/descriptor_ops.hpp b/asio/include/asio/detail/descriptor_ops.hpp index 6de34f62..e886b27f 100644 --- a/asio/include/asio/detail/descriptor_ops.hpp +++ b/asio/include/asio/detail/descriptor_ops.hpp @@ -58,17 +58,28 @@ inline int close(int d, asio::error_code& ec) return error_wrapper(::close(d), ec); } +inline void init_buf_iov_base(void*& base, void* addr) +{ + base = addr; +} + +template +inline void init_buf_iov_base(T& base, void* addr) +{ + base = static_cast(addr); +} + typedef iovec buf; inline void init_buf(buf& b, void* data, size_t size) { - b.iov_base = data; + init_buf_iov_base(b.iov_base, data); b.iov_len = size; } inline void init_buf(buf& b, const void* data, size_t size) { - b.iov_base = const_cast(data); + init_buf_iov_base(b.iov_base, const_cast(data)); b.iov_len = size; }