With a custom allocator which specifies 16-bit size and difference types, the next_capacity calculation of vector causes an error:
#include <boost/container/vector.hpp>
class CustomAllocator
{
public:
typedef int value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef unsigned short size_type;
typedef short difference_type;
pointer allocate(size_type count);
void deallocate(pointer ptr, size_type count);
};
int main()
{
boost::container::vector<int, CustomAllocator> test;
test.push_back(1);
return 0;
}
Compiling with Visual C++ 2019, the above gives an error at container/detail/next_capacity.hpp(56)
'boost::container::dtl::max_value': no matching overloaded function found
The issue is caused by cur_cap+min_cap automatically widening to int, which then fails to match any max_value implementation. Adding a cast around the addition resolves the issue:
With a custom allocator which specifies 16-bit size and difference types, the next_capacity calculation of vector causes an error:
Compiling with Visual C++ 2019, the above gives an error at container/detail/next_capacity.hpp(56)
'boost::container::dtl::max_value': no matching overloaded function found
The issue is caused by cur_cap+min_cap automatically widening to int, which then fails to match any max_value implementation. Adding a cast around the addition resolves the issue: