mirror of
				https://github.com/NoelFB/blah.git
				synced 2025-11-04 01:41:34 +08:00 
			
		
		
		
	fixed vector copy constructor bug
This commit is contained in:
		@ -80,7 +80,7 @@ namespace Blah
 | 
				
			|||||||
		m_count = m_capacity = 0;
 | 
							m_count = m_capacity = 0;
 | 
				
			||||||
		reserve(src.m_capacity);
 | 
							reserve(src.m_capacity);
 | 
				
			||||||
		for (int i = 0; i < src.m_count; i++)
 | 
							for (int i = 0; i < src.m_count; i++)
 | 
				
			||||||
			m_buffer[i] = src.m_buffer[i];
 | 
								new (m_buffer + i) T(src.m_buffer[i]);
 | 
				
			||||||
		m_count = src.m_count;
 | 
							m_count = src.m_count;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -213,13 +213,17 @@ namespace Blah
 | 
				
			|||||||
	template<class T>
 | 
						template<class T>
 | 
				
			||||||
	inline void Vector<T>::push_back(const T& item)
 | 
						inline void Vector<T>::push_back(const T& item)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		emplace_back(item);
 | 
							reserve(m_count + 1);
 | 
				
			||||||
 | 
							new (m_buffer + m_count) T(item);
 | 
				
			||||||
 | 
							m_count++;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	template<class T>
 | 
						template<class T>
 | 
				
			||||||
	inline void Vector<T>::push_back(T&& item)
 | 
						inline void Vector<T>::push_back(T&& item)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		emplace_back(std::move(item));
 | 
							reserve(m_count + 1);
 | 
				
			||||||
 | 
							new (m_buffer + m_count) T(std::move(item));
 | 
				
			||||||
 | 
							m_count++;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	template<class T>
 | 
						template<class T>
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user