Use smallest viable size in valptridx::array_base_count_type
This commit is contained in:
parent
385d51b18e
commit
bf7ba07e1f
|
@ -37,8 +37,15 @@ template <typename managed_type>
|
|||
class valptridx<managed_type>::array_base_count_type
|
||||
{
|
||||
protected:
|
||||
/* Use the smallest size that will store all legal values. Currently,
|
||||
* no user has a maximum size that needs more than uint16_t, so reject
|
||||
* attempts to use that size. This protects against silently getting
|
||||
* the wrong result if a future change raises the maximum size above
|
||||
* uint16_t.
|
||||
*/
|
||||
using count_type = typename std::conditional<(array_size <= UINT8_MAX), uint8_t, typename std::conditional<(array_size <= UINT16_MAX), uint16_t, void>::type>::type;
|
||||
union {
|
||||
unsigned count;
|
||||
count_type count;
|
||||
/*
|
||||
* Use DXX_VALPTRIDX_FOR_EACH_PPI_TYPE to generate empty union
|
||||
* members based on basic_{i,v}val_member_factory
|
||||
|
@ -55,11 +62,11 @@ protected:
|
|||
{
|
||||
}
|
||||
public:
|
||||
unsigned get_count() const
|
||||
count_type get_count() const
|
||||
{
|
||||
return count;
|
||||
}
|
||||
void set_count(const unsigned c)
|
||||
void set_count(const count_type c)
|
||||
{
|
||||
count = c;
|
||||
}
|
||||
|
|
|
@ -775,7 +775,7 @@ int wall_remove_side(const vmsegptridx_t seg, const sidenum_t side)
|
|||
}
|
||||
|
||||
{
|
||||
const auto num_walls = Walls.get_count();
|
||||
const std::size_t num_walls{Walls.get_count()};
|
||||
auto &&sr = partial_const_range(Walls, static_cast<unsigned>(lower_wallnum) + 2, num_walls);
|
||||
std::move(sr.begin(), sr.end(), partial_range(Walls, static_cast<unsigned>(lower_wallnum), num_walls - 2).begin());
|
||||
Walls.set_count(num_walls - 2);
|
||||
|
|
Loading…
Reference in a new issue