Add non-empty version of push_next() to Vector.

This commit is contained in:
Bartosz Taudul 2020-03-21 17:56:24 +01:00
parent d262ca53ea
commit 159cf8c477

View File

@ -114,6 +114,7 @@ public:
tracy_force_inline void push_back_non_empty( const T& v ) tracy_force_inline void push_back_non_empty( const T& v )
{ {
assert( m_capacity != MaxCapacity() ); assert( m_capacity != MaxCapacity() );
assert( m_ptr );
if( m_size == CapacityNoNullptrCheck() ) AllocMore(); if( m_size == CapacityNoNullptrCheck() ) AllocMore();
new(m_ptr+m_size) T( v ); new(m_ptr+m_size) T( v );
m_size++; m_size++;
@ -143,6 +144,15 @@ public:
return m_ptr[m_size++]; return m_ptr[m_size++];
} }
tracy_force_inline T& push_next_non_empty()
{
assert( m_capacity != MaxCapacity() );
assert( m_ptr );
if( m_size == CapacityNoNullptrCheck() ) AllocMore();
new(m_ptr+m_size) T();
return m_ptr[m_size++];
}
tracy_force_inline T& push_next_no_space_check() tracy_force_inline T& push_next_no_space_check()
{ {
assert( m_capacity != MaxCapacity() ); assert( m_capacity != MaxCapacity() );