Skip to content

Commit

Permalink
Use generic iterator range instead of casting between iterator types.…
Browse files Browse the repository at this point in the history
… Avoids an issue with Microsoft's checked iterators and is likely more correct/portable. (#852)
  • Loading branch information
LoopinFool authored and deanberris committed Jul 19, 2018
1 parent 38e48c9 commit ca95f04
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions boost/network/protocol/http/client/connection/async_normal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ struct chunk_encoding_parser {
size_t chunk_size;
buffer_type buffer;

void update_chunk_size(char_const_range const &range) {
template<typename T>
void update_chunk_size(boost::iterator_range<T> const &range) {
if (range.empty()) return;
std::stringstream ss;
ss << std::hex << range;
Expand All @@ -61,7 +62,8 @@ struct chunk_encoding_parser {
chunk_size = (chunk_size << (range.size() * 4)) | size;
}

char_const_range operator()(char_const_range const &range) {
template<typename T>
char_const_range operator()(boost::iterator_range<T> const &range) {
auto iter = boost::begin(range);
auto begin = iter;
auto pos = boost::begin(buffer);
Expand Down Expand Up @@ -485,10 +487,8 @@ struct http_async_connection
const auto parse_buffer_size = parse_chunk_encoding.buffer.size();
for (size_t i = 0; i < this->partial_parsed.size(); i += parse_buffer_size) {
auto range = parse_chunk_encoding(boost::make_iterator_range(
static_cast<
typename chunk_encoding_parser_type::const_iterator>(this->partial_parsed.data()) + i,
static_cast<
typename chunk_encoding_parser_type::const_iterator>(this->partial_parsed.data()) +
this->partial_parsed.cbegin() + i,
this->partial_parsed.cbegin() +
std::min(i + parse_buffer_size, this->partial_parsed.size())));
body_string.append(boost::begin(range), boost::end(range));
}
Expand Down

0 comments on commit ca95f04

Please sign in to comment.