*: protect against minmax (#862)

This commit is contained in:
Alexandr Timofeev
2022-04-07 15:28:30 +03:00
committed by GitHub
parent 22757e064f
commit bf4252394c
3 changed files with 9 additions and 9 deletions

View File

@@ -682,7 +682,7 @@ public:
* @return Number of elements removed (either 0 or 1).
*/
size_type erase(const key_type &key) {
for(size_type *curr = sparse.first().data() + key_to_bucket(key); *curr != std::numeric_limits<size_type>::max(); curr = &packed.first()[*curr].next) {
for(size_type *curr = sparse.first().data() + key_to_bucket(key); *curr != (std::numeric_limits<size_type>::max)(); curr = &packed.first()[*curr].next) {
if(packed.second()(packed.first()[*curr].element.first, key)) {
const auto index = *curr;
*curr = packed.first()[*curr].next;
@@ -832,7 +832,7 @@ public:
* @return An iterator to the end of the given bucket.
*/
[[nodiscard]] const_local_iterator cend([[maybe_unused]] const size_type index) const {
return {packed.first().begin(), std::numeric_limits<size_type>::max()};
return {packed.first().begin(), (std::numeric_limits<size_type>::max)()};
}
/**
@@ -850,7 +850,7 @@ public:
* @return An iterator to the end of the given bucket.
*/
[[nodiscard]] local_iterator end([[maybe_unused]] const size_type index) {
return {packed.first().begin(), std::numeric_limits<size_type>::max()};
return {packed.first().begin(), (std::numeric_limits<size_type>::max)()};
}
/**
@@ -924,7 +924,7 @@ public:
if(const auto sz = next_power_of_two(value); sz != bucket_count()) {
sparse.first().resize(sz);
std::fill(sparse.first().begin(), sparse.first().end(), std::numeric_limits<size_type>::max());
std::fill(sparse.first().begin(), sparse.first().end(), (std::numeric_limits<size_type>::max)());
for(size_type pos{}, last = size(); pos < last; ++pos) {
const auto index = key_to_bucket(packed.first()[pos].element.first);

View File

@@ -572,7 +572,7 @@ public:
* @return Number of elements removed (either 0 or 1).
*/
size_type erase(const value_type &value) {
for(size_type *curr = sparse.first().data() + value_to_bucket(value); *curr != std::numeric_limits<size_type>::max(); curr = &packed.first()[*curr].first) {
for(size_type *curr = sparse.first().data() + value_to_bucket(value); *curr != (std::numeric_limits<size_type>::max)(); curr = &packed.first()[*curr].first) {
if(packed.second()(packed.first()[*curr].second, value)) {
const auto index = *curr;
*curr = packed.first()[*curr].first;
@@ -685,7 +685,7 @@ public:
* @return An iterator to the end of the given bucket.
*/
[[nodiscard]] const_local_iterator cend([[maybe_unused]] const size_type index) const {
return {packed.first().begin(), std::numeric_limits<size_type>::max()};
return {packed.first().begin(), (std::numeric_limits<size_type>::max)()};
}
/**
@@ -703,7 +703,7 @@ public:
* @return An iterator to the end of the given bucket.
*/
[[nodiscard]] local_iterator end([[maybe_unused]] const size_type index) {
return {packed.first().begin(), std::numeric_limits<size_type>::max()};
return {packed.first().begin(), (std::numeric_limits<size_type>::max)()};
}
/**
@@ -777,7 +777,7 @@ public:
if(const auto sz = next_power_of_two(value); sz != bucket_count()) {
sparse.first().resize(sz);
std::fill(sparse.first().begin(), sparse.first().end(), std::numeric_limits<size_type>::max());
std::fill(sparse.first().begin(), sparse.first().end(), (std::numeric_limits<size_type>::max)());
for(size_type pos{}, last = size(); pos < last; ++pos) {
const auto index = value_to_bucket(packed.first()[pos].second);

View File

@@ -255,7 +255,7 @@ public:
basic_view(storage_type<Component> &...component, const storage_type<Exclude> &...epool) ENTT_NOEXCEPT
: pools{&component...},
filter{&epool...},
view{std::min<const base_type *>({&component...}, [](auto *lhs, auto *rhs) { return lhs->size() < rhs->size(); })} {}
view{(std::min)({&static_cast<const base_type &>(component)...}, [](auto *lhs, auto *rhs) { return lhs->size() < rhs->size(); })} {}
/**
* @brief Creates a new view driven by a given component in its iterations.