Lyc*_*ess 6 c++ scope-resolution new-operator
检查MS directX 11 DXUT示例时,出现以下代码:
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;
}
Run Code Online (Sandbox Code Playgroud)
这可以在我的DXSDK版本(2010年6月)第428行的DXUTmisc.h中找到.我想知道那个::新事物....我正在尝试谷歌搜索堆栈溢出但似乎搜索引擎在我在搜索栏中输入":: new"时丢弃了两个冒号... .
| 归档时间: |
|
| 查看次数: |
1928 次 |
| 最近记录: |