Update array.hpp (#3769)

* Update array.hpp

Problem:Calling back on an empty container causes undefined behavior.
Solution:Check with the function empty()

* Create xqcool.mq

Adds relicensing grant
This commit is contained in:
xqcool
2020-01-01 17:37:51 +08:00
committed by Luca Boccassi
parent 246cc77efc
commit 382c6d7186
2 changed files with 18 additions and 2 deletions

View File

@@ -100,8 +100,9 @@ template <typename T, int ID = 0> class array_t
inline void erase (size_type index_)
{
if (_items.back ())
((item_t *) _items.back ())->set_array_index ((int) index_);
if (_items.empty ())
return;
((item_t *) _items.back ())->set_array_index ((int) index_);
_items[index_] = _items.back ();
_items.pop_back ();
}