|
Boost-Commit : |
From: chris_at_[hidden]
Date: 2008-09-01 19:05:05
Author: chris_kohlhoff
Date: 2008-09-01 19:05:05 EDT (Mon, 01 Sep 2008)
New Revision: 48525
URL: http://svn.boost.org/trac/boost/changeset/48525
Log:
Use templates to handle iovec structures that have an iov_base member of
type char*.
Text files modified:
trunk/boost/asio/detail/descriptor_ops.hpp | 15 +++++++++++++--
trunk/boost/asio/detail/socket_ops.hpp | 15 +++++++++++++--
2 files changed, 26 insertions(+), 4 deletions(-)
Modified: trunk/boost/asio/detail/descriptor_ops.hpp
==============================================================================
--- trunk/boost/asio/detail/descriptor_ops.hpp (original)
+++ trunk/boost/asio/detail/descriptor_ops.hpp 2008-09-01 19:05:05 EDT (Mon, 01 Sep 2008)
@@ -59,17 +59,28 @@
return error_wrapper(::close(d), ec);
}
+inline void init_buf_iov_base(void*& base, void* addr)
+{
+ base = addr;
+}
+
+template <typename T>
+inline void init_buf_iov_base(T& base, void* addr)
+{
+ base = static_cast<T>(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<void*>(data);
+ init_buf_iov_base(b.iov_base, const_cast<void*>(data));
b.iov_len = size;
}
Modified: trunk/boost/asio/detail/socket_ops.hpp
==============================================================================
--- trunk/boost/asio/detail/socket_ops.hpp (original)
+++ trunk/boost/asio/detail/socket_ops.hpp 2008-09-01 19:05:05 EDT (Mon, 01 Sep 2008)
@@ -203,6 +203,17 @@
return result;
}
+inline void init_buf_iov_base(void*& base, void* addr)
+{
+ base = addr;
+}
+
+template <typename T>
+inline void init_buf_iov_base(T& base, void* addr)
+{
+ base = static_cast<T>(addr);
+}
+
#if defined(BOOST_WINDOWS) || defined(__CYGWIN__)
typedef WSABUF buf;
#else // defined(BOOST_WINDOWS) || defined(__CYGWIN__)
@@ -215,7 +226,7 @@
b.buf = static_cast<char*>(data);
b.len = static_cast<u_long>(size);
#else // defined(BOOST_WINDOWS) || defined(__CYGWIN__)
- b.iov_base = data;
+ init_buf_iov_base(b.iov_base, data);
b.iov_len = size;
#endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__)
}
@@ -226,7 +237,7 @@
b.buf = static_cast<char*>(const_cast<void*>(data));
b.len = static_cast<u_long>(size);
#else // defined(BOOST_WINDOWS) || defined(__CYGWIN__)
- b.iov_base = const_cast<void*>(data);
+ init_buf_iov_base(b.iov_base, const_cast<void*>(data));
b.iov_len = size;
#endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__)
}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk