I was looking through some of boost container memory pool code and came across the following which I do not understand, complete source .cpp .h
//Limit max value
std::size_t blocks_per_chunk
= boost::container::dtl::min_value(max_blocks_per_chunk, next_blocks_per_chunk);
//Avoid overflow
blocks_per_chunk
= boost::container::dtl::min_value(blocks_per_chunk, std::size_t(-1)/pool_block);
Specifically I do not understand how the second line of code "avoids overflow".
blocks_per_chunk
is already set to be the minimum of next and max_blocks_per_chunk
. So this should already be in a valid range.
What does dividing -1
by pool_block do in this situation?