Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6e4253c

Browse files
committed
SFINAE for choosing 'write' overload
Aside from adding an additional clarification in the documentation forthe macro defining the size of a page, this change makes the user-facing'write' implementation use SFINAE to choose whether to deal with thebuffer provided as a buffer that doesn't need to be copied (derives fromBoost.Asio's const_buffer type) or whether it's something that needs tobe copied (in the case of any other range).In the future there should be other overloads which deal with explicitBoost.Range iterator ranges, and maybe specific types.
1 parent63c6510 commit6e4253c

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include<boost/utility/typed_in_place_factory.hpp>
2626
#include<boost/thread/locks.hpp>
2727
#include<boost/thread/recursive_mutex.hpp>
28+
#include<boost/utility/enable_if.hpp>
2829
#include<list>
2930
#include<vector>
3031
#include<iterator>
@@ -36,6 +37,10 @@
3637
* This is the maximum size though and Boost.Asio's internal representation
3738
* of a streambuf would make appropriate decisions on how big a buffer
3839
* is to begin with.
40+
*
41+
* This kinda assumes that a page is by default 4096. Since we're using
42+
* the default allocator with the static buffers, it's not guaranteed that
43+
* the static buffers will be page-aligned when they are allocated.
3944
*/
4045
#defineBOOST_NETWORK_HTTP_SERVER_CONNECTION_HEADER_BUFFER_MAX_SIZE4096
4146
#endif/* BOOST_NETWORK_HTTP_SERVER_CONNECTION_HEADER_BUFFER_MAX_SIZE*/
@@ -209,14 +214,16 @@ namespace boost { namespace network { namespace http {
209214
}
210215

211216
template<classRange,classCallback>
212-
voidwrite(Rangeconst & range, Callbackconst & callback) {
217+
typename disable_if<is_base_of<asio::const_buffer, Range>,void>::type
218+
write(Rangeconst & range, Callbackconst & callback) {
213219
lock_guardlock(headers_mutex);
214220
if (error_encountered)boost::throw_exception(boost::system::system_error(*error_encountered));
215221
write_impl(boost::make_iterator_range(range), callback);
216222
}
217223

218224
template<classConstBufferSeq,classCallback>
219-
voidwrite_vec(ConstBufferSeqconst & seq, Callbackconst & callback)
225+
typename enable_if<is_base_of<asio::const_buffer, ConstBufferSeq>,void>::type
226+
write(ConstBufferSeqconst & seq, Callbackconst & callback)
220227
{
221228
write_vec_impl(seq, callback,shared_array_list(),shared_buffers());
222229
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp