Skip to content

Commit

Permalink
Reduce conflict between std::min and macros
Browse files Browse the repository at this point in the history
Adjust usage of std::min to be more compatible with systems that define
a min(...) macro
  • Loading branch information
zaphoyd committed Aug 9, 2014
1 parent e203dbe commit 122d4e2
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 5 deletions.
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
HEAD
- Compatibility: Adjust usage of std::min to be more compatible with systems
that define a min(...) macro.

0.3.0 - 2014-08-10
- Feature: Adds `start_perpetual` and `stop_perpetual` methods to asio transport
Expand Down
2 changes: 1 addition & 1 deletion websocketpp/extensions/permessage_deflate/enabled.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ class enabled {
m_s2c_max_window_bits = bits;
break;
case mode::largest:
m_s2c_max_window_bits = std::min(bits,m_s2c_max_window_bits);
m_s2c_max_window_bits = (std::min)(bits,m_s2c_max_window_bits);
break;
case mode::smallest:
m_s2c_max_window_bits = min_s2c_max_window_bits;
Expand Down
2 changes: 1 addition & 1 deletion websocketpp/processors/hybi00.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class hybi00 : public processor<config> {
// of warning or exception.
const std::string& key3 = req.get_header("Sec-WebSocket-Key3");
std::copy(key3.c_str(),
key3.c_str()+std::min(static_cast<size_t>(8), key3.size()),
key3.c_str()+(std::min)(static_cast<size_t>(8), key3.size()),
&key_final[8]);

res.append_header(
Expand Down
4 changes: 2 additions & 2 deletions websocketpp/processors/hybi13.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ class hybi13 : public processor<config> {
} else if (m_state == EXTENSION) {
m_state = APPLICATION;
} else if (m_state == APPLICATION) {
size_t bytes_to_process = std::min(m_bytes_needed,len-p);
size_t bytes_to_process = (std::min)(m_bytes_needed,len-p);

if (bytes_to_process > 0) {
p += this->process_payload_bytes(buf+p,bytes_to_process,ec);
Expand Down Expand Up @@ -670,7 +670,7 @@ class hybi13 : public processor<config> {

/// Reads bytes from buf into m_extended_header
size_t copy_extended_header_bytes(uint8_t const * buf, size_t len) {
size_t bytes_to_read = std::min(m_bytes_needed,len);
size_t bytes_to_read = (std::min)(m_bytes_needed,len);

std::copy(buf,buf+bytes_to_read,m_extended_header.bytes+m_cursor);
m_cursor += bytes_to_read;
Expand Down
2 changes: 1 addition & 1 deletion websocketpp/transport/iostream/connection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ class connection : public lib::enable_shared_from_this< connection<config> > {
return 0;
}

size_t bytes_to_copy = std::min(len,m_len-m_cursor);
size_t bytes_to_copy = (std::min)(len,m_len-m_cursor);

std::copy(buf,buf+bytes_to_copy,m_buf+m_cursor);

Expand Down

0 comments on commit 122d4e2

Please sign in to comment.