Skip to content

Commit 897de7b

Browse files
committed
Fixed async_connection::write() SFINAE-isation
Overloaded function selection based on ConstBufferSeq::value_type. http_server_async_less_copy test fixed accordingly.
1 parent 6ca564d commit 897de7b

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

boost/network/protocol/http/server/async_connection.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -214,15 +214,15 @@ namespace boost { namespace network { namespace http {
214214
}
215215

216216
template <class Range, class Callback>
217-
typename disable_if<is_base_of<asio::const_buffer, Range>, void>::type
217+
typename disable_if<is_base_of<asio::const_buffer, typename Range::value_type>, void>::type
218218
write(Range const & range, Callback const & callback) {
219219
lock_guard lock(headers_mutex);
220220
if (error_encountered) boost::throw_exception(boost::system::system_error(*error_encountered));
221221
write_impl(boost::make_iterator_range(range), callback);
222222
}
223223

224224
template <class ConstBufferSeq, class Callback>
225-
typename enable_if<is_base_of<asio::const_buffer, ConstBufferSeq>, void>::type
225+
typename enable_if<is_base_of<asio::const_buffer, typename ConstBufferSeq::value_type>, void>::type
226226
write(ConstBufferSeq const & seq, Callback const & callback)
227227
{
228228
write_vec_impl(seq, callback, shared_array_list(), shared_buffers());

libs/network/test/http_server_async_less_copy.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
#define BOOST_TEST_MODULE HTTP Asynchronous Server Tests
88

9+
#include <vector>
10+
911
#include <boost/config/warning_disable.hpp>
1012
#include <boost/network/include/http/server.hpp>
1113
#include <boost/network/utils/thread_pool.hpp>
@@ -51,9 +53,9 @@ struct async_hello_world {
5153
static char const * hello_world = "Hello, World!";
5254
connection->set_status(server::connection::ok);
5355
connection->set_headers(boost::make_iterator_range(headers, headers+3));
54-
connection->write(
55-
boost::asio::const_buffers_1(hello_world, 13)
56-
, boost::bind(&async_hello_world::error, this, _1));
56+
std::vector<boost::asio::const_buffer> iovec;
57+
iovec.push_back(boost::asio::const_buffer(hello_world, 13));
58+
connection->write(iovec, boost::bind(&async_hello_world::error, this, _1));
5759
}
5860
}
5961

0 commit comments

Comments
 (0)