When examining the MS directX 11 DXUT example, the following code appeared:
template<typename TYPE> HRESULT CGrowableArray <TYPE>::SetSize( int nNewMaxSize )
{
int nOldSize = m_nSize;
if( nOldSize > nNewMaxSize )
{
assert( m_pData );
if( m_pData )
{
// Removing elements. Call dtor.
for( int i = nNewMaxSize; i < nOldSize; ++i )
m_pData[i].~TYPE();
}
}
// Adjust buffer. Note that there's no need to check for error
// since if it happens, nOldSize == nNewMaxSize will be true.)
HRESULT hr = SetSizeInternal( nNewMaxSize );
if( nOldSize < nNewMaxSize )
{
assert( m_pData );
if( m_pData )
{
// Adding elements. Call ctor.
for( int i = nOldSize; i < nNewMaxSize; ++i )
::new ( &m_pData[i] ) TYPE;
}
}
return hr;
}
This can be found in DXUTmisc.h on line 428 on my version of DXSDK (June2010). I'm wondering about that ::new thing....I'm trying to Google and search on stack overflow but seems the searching engine is discarding the two colons when I type "::new" in the search bar....