Add single-value Vector constructor.

This commit is contained in:
Bartosz Taudul 2018-07-22 16:01:58 +02:00
parent be40ee9dbc
commit eb1475ebd4

View File

@ -34,6 +34,15 @@ public:
src.m_ptr = nullptr; src.m_ptr = nullptr;
} }
Vector( const T& value )
: m_ptr( new T[1] )
, m_size( 1 )
, m_capacity( 0 )
{
memUsage.fetch_add( sizeof( T ), std::memory_order_relaxed );
m_ptr[0] = value;
}
~Vector() ~Vector()
{ {
memUsage.fetch_sub( Capacity() * sizeof( T ), std::memory_order_relaxed ); memUsage.fetch_sub( Capacity() * sizeof( T ), std::memory_order_relaxed );