Sfoglia il codice sorgente

core: initialize with proper allocator

Daniele Bartolini 5 anni fa
parent
commit
e92722d927

+ 4 - 1
src/core/containers/hash_map.inl

@@ -394,7 +394,10 @@ HashMap<TKey, TValue, Hash, KeyEqual>& HashMap<TKey, TValue, Hash, KeyEqual>::op
 		{
 			const u32 index = other._index[i].index;
 			if (index != hash_map_internal::FREE && !hash_map_internal::is_deleted(index))
-				new (&_data[i]) Entry(other._data[i]);
+			{
+				new (&_data[i]) PAIR(TKey, TValue)(*_allocator);
+				_data[i] = other._data[i];
+			}
 		}
 	}
 	return *this;

+ 4 - 1
src/core/containers/hash_set.inl

@@ -369,7 +369,10 @@ HashSet<TKey, Hash, KeyEqual>& HashSet<TKey, Hash, KeyEqual>::operator=(const Ha
 		{
 			const u32 index = other._index[i].index;
 			if (index != hash_set_internal::FREE && !hash_set_internal::is_deleted(index))
-				new (&_data[i]) TKey(other._data[i]);
+			{
+				construct<TKey>(_data + i, *_allocator, IS_ALLOCATOR_AWARE_TYPE(TKey)());
+				_data[i] = other._data[i];
+			}
 		}
 	}
 	return *this;

+ 4 - 1
src/core/containers/vector.inl

@@ -315,7 +315,10 @@ inline const Vector<T>& Vector<T>::operator=(const Vector<T>& other)
 	vector::resize(*this, size);
 
 	for (u32 i = 0; i < size; ++i)
-		new (&_data[i]) T(other._data[i]);
+	{
+		construct<T>(_data + i, *_allocator, IS_ALLOCATOR_AWARE_TYPE(T)());
+		_data[i] = other._data[i];
+	}
 
 	return *this;
 }