Fixed warnings on Windows due to max/min macro

This commit is contained in:
yhirose 2020-03-16 13:58:09 -04:00
parent 6e46ccb37c
commit 685533ba50

View file

@ -41,7 +41,7 @@
#endif
#ifndef CPPHTTPLIB_PAYLOAD_MAX_LENGTH
#define CPPHTTPLIB_PAYLOAD_MAX_LENGTH (std::numeric_limits<size_t>::max())
#define CPPHTTPLIB_PAYLOAD_MAX_LENGTH ((std::numeric_limits<size_t>::max)())
#endif
#ifndef CPPHTTPLIB_RECV_BUFSIZ
@ -50,7 +50,7 @@
#ifndef CPPHTTPLIB_THREAD_POOL_COUNT
#define CPPHTTPLIB_THREAD_POOL_COUNT \
(std::max(1u, std::thread::hardware_concurrency() - 1))
((std::max)(1u, std::thread::hardware_concurrency() - 1))
#endif
/*
@ -1785,7 +1785,7 @@ inline bool read_content_with_length(Stream &strm, uint64_t len,
uint64_t r = 0;
while (r < len) {
auto read_len = static_cast<size_t>(len - r);
auto n = strm.read(buf, std::min(read_len, CPPHTTPLIB_RECV_BUFSIZ));
auto n = strm.read(buf, (std::min)(read_len, CPPHTTPLIB_RECV_BUFSIZ));
if (n <= 0) { return false; }
if (!out(buf, static_cast<size_t>(n))) { return false; }
@ -1805,7 +1805,7 @@ inline void skip_content_with_length(Stream &strm, uint64_t len) {
uint64_t r = 0;
while (r < len) {
auto read_len = static_cast<size_t>(len - r);
auto n = strm.read(buf, std::min(read_len, CPPHTTPLIB_RECV_BUFSIZ));
auto n = strm.read(buf, (std::min)(read_len, CPPHTTPLIB_RECV_BUFSIZ));
if (n <= 0) { return; }
r += static_cast<uint64_t>(n);
}
@ -4005,7 +4005,7 @@ inline bool Client::process_request(Stream &strm, const Request &req,
}
int dummy_status;
if (!detail::read_content(strm, res, std::numeric_limits<size_t>::max(),
if (!detail::read_content(strm, res, (std::numeric_limits<size_t>::max)(),
dummy_status, req.progress, out)) {
return false;
}
@ -4022,7 +4022,7 @@ inline bool Client::process_and_close_socket(
std::function<bool(Stream &strm, bool last_connection,
bool &connection_close)>
callback) {
request_count = std::min(request_count, keep_alive_max_count_);
request_count = (std::min)(request_count, keep_alive_max_count_);
return detail::process_and_close_socket(true, sock, request_count,
read_timeout_sec_, read_timeout_usec_,
callback);