Revisit boost library min/max guidance

refs #170
This commit is contained in:
Sergey M․
2017-11-06 03:20:46 +07:00
committed by Vinnie Falco
parent babb6bd59f
commit 8e75ed26d1
8 changed files with 22 additions and 16 deletions

View File

@@ -1,3 +1,9 @@
Version 139:
* Revisit boost library min/max guidance
--------------------------------------------------------------------------------
Version 138: Version 138:
* Tidy up some documentation * Tidy up some documentation

View File

@@ -124,7 +124,7 @@ public:
void void
commit(std::size_t n) commit(std::size_t n)
{ {
out_ += std::min<std::size_t>(n, last_ - out_); out_ += (std::min<std::size_t>)(n, last_ - out_);
} }
/// Remove bytes from the input sequence. /// Remove bytes from the input sequence.

View File

@@ -263,9 +263,9 @@ prepare(std::size_t n) ->
BOOST_THROW_EXCEPTION(std::length_error{ BOOST_THROW_EXCEPTION(std::length_error{
"basic_flat_buffer overflow"}); "basic_flat_buffer overflow"});
// allocate a new buffer // allocate a new buffer
auto const new_size = std::min<std::size_t>( auto const new_size = (std::min<std::size_t>)(
max_, max_,
std::max<std::size_t>(2 * len, len + n)); (std::max<std::size_t>)(2 * len, len + n));
auto const p = alloc_traits::allocate( auto const p = alloc_traits::allocate(
this->member(), new_size); this->member(), new_size);
if(begin_) if(begin_)

View File

@@ -700,9 +700,9 @@ prepare(size_type n) ->
{ {
static auto const growth_factor = 2.0f; static auto const growth_factor = 2.0f;
auto const size = auto const size =
std::min<std::size_t>( (std::min<std::size_t>)(
max_ - total, max_ - total,
std::max<std::size_t>({ (std::max<std::size_t>)({
static_cast<std::size_t>( static_cast<std::size_t>(
in_size_ * growth_factor - in_size_), in_size_ * growth_factor - in_size_),
512, 512,

View File

@@ -45,9 +45,9 @@ read_size(DynamicBuffer& buffer,
auto const size = buffer.size(); auto const size = buffer.size();
auto const limit = buffer.max_size() - size; auto const limit = buffer.max_size() - size;
BOOST_ASSERT(size <= buffer.max_size()); BOOST_ASSERT(size <= buffer.max_size());
return std::min<std::size_t>( return (std::min<std::size_t>)(
std::max<std::size_t>(512, buffer.capacity() - size), (std::max<std::size_t>)(512, buffer.capacity() - size),
std::min<std::size_t>(max_size, limit)); (std::min<std::size_t>)(max_size, limit));
} }
} // detail } // detail

View File

@@ -167,7 +167,7 @@ loop:
maybe_need_more(p, n, ec); maybe_need_more(p, n, ec);
if(ec) if(ec)
goto done; goto done;
parse_start_line(p, p + std::min<std::size_t>( parse_start_line(p, p + (std::min<std::size_t>)(
header_limit_, n), ec, is_request{}); header_limit_, n), ec, is_request{});
if(ec) if(ec)
{ {
@@ -198,7 +198,7 @@ loop:
maybe_need_more(p, n, ec); maybe_need_more(p, n, ec);
if(ec) if(ec)
goto done; goto done;
parse_fields(p, p + std::min<std::size_t>( parse_fields(p, p + (std::min<std::size_t>)(
header_limit_, n), ec); header_limit_, n), ec);
if(ec) if(ec)
{ {

View File

@@ -417,8 +417,8 @@ operator()()
} }
auto& r = sr_.reader_impl(); auto& r = sr_.reader_impl();
boost::winapi::DWORD_ const nNumberOfBytesToWrite = boost::winapi::DWORD_ const nNumberOfBytesToWrite =
std::min<boost::winapi::DWORD_>( (std::min<boost::winapi::DWORD_>)(
beast::detail::clamp(std::min<std::uint64_t>( beast::detail::clamp((std::min<std::uint64_t>)(
r.body_.last_ - r.pos_, sr_.limit())), r.body_.last_ - r.pos_, sr_.limit())),
2147483646); 2147483646);
boost::asio::windows::overlapped_ptr overlapped{ boost::asio::windows::overlapped_ptr overlapped{
@@ -514,8 +514,8 @@ write_some(
if(ec) if(ec)
return 0; return 0;
boost::winapi::DWORD_ const nNumberOfBytesToWrite = boost::winapi::DWORD_ const nNumberOfBytesToWrite =
std::min<boost::winapi::DWORD_>( (std::min<boost::winapi::DWORD_>)(
beast::detail::clamp(std::min<std::uint64_t>( beast::detail::clamp((std::min<std::uint64_t>)(
r.body_.last_ - r.pos_, sr.limit())), r.body_.last_ - r.pos_, sr.limit())),
2147483646); 2147483646);
auto const bSuccess = ::TransmitFile( auto const bSuccess = ::TransmitFile(

View File

@@ -277,7 +277,7 @@ pmd_negotiate(
s += "; client_no_context_takeover"; s += "; client_no_context_takeover";
if(offer.server_max_window_bits != 0) if(offer.server_max_window_bits != 0)
config.server_max_window_bits = std::min( config.server_max_window_bits = (std::min)(
offer.server_max_window_bits, offer.server_max_window_bits,
o.server_max_window_bits); o.server_max_window_bits);
else else
@@ -326,7 +326,7 @@ pmd_negotiate(
default: default:
// extension parameter has value in [8..15] // extension parameter has value in [8..15]
config.client_max_window_bits = std::min( config.client_max_window_bits = (std::min)(
o.client_max_window_bits, o.client_max_window_bits,
offer.client_max_window_bits); offer.client_max_window_bits);
s += "; client_max_window_bits="; s += "; client_max_window_bits=";