I have these templates in a header:
template< typename T > T* HLA_newObject( CHighLevelAssemblerBase* self ) __QCMP_THROW
{
void* addr = self->getZone().zalloc( sizeof(T) );
return new( addr ) T( self );
}
template< typename T, typename P1 > T* HLA_newObject( CHighLevelAssemblerBase* self, P1 p1 ) __QCMP_THROW
{
void* addr = self->getZone().zalloc( sizeof(T) );
return new( addr ) T( self, p1 ); }
template< typename T, typename P1, typename P2 > T* HLA_newObject( CHighLevelAssemblerBase* self, P1 p1, P2 p2 ) __QCMP_THROW
{
void* addr = self->getZone().zalloc( sizeof(T) );
return new( addr ) T( self, p1, p2 );
}
which do placement new of some objects in preallocated memory.
I'm getting this error:
.../HighLevelAssemblerBase.h(55): error C2660: 'operator new' : function does not take 2 arguments
from the VS2010 compiler at the line marked above.
The reference is to this line in the .cpp file:
CEAlign* pAlign = HLA_newObject< CEAlign >( this, m );
despite the following lines from elsewhere in the same module not causing the compiler any issue at all.
CEVariableHint* e = HLA_newObject< CEVariableHint >( this, vdata, hintId, hintValue );
CETarget* target = HLA_newObject< CETarget >( this, label );
CERet* eRet = HLA_newObject< CERet >( this, fn, first, second );
I must be doing something wrong and it's probably pretty obvious but for the life of me I can't see what it could be? Whatever it is it surely isn't an attempt to pass 2 parameters to
new
.
ADDENDUM:
The only constructor for the 2 parameter case that works,
CETarget
is:
CETarget( nsArch::CHighLevelAssemblerBase* c, const CLabel& target ) __QCMP_THROW;
For
CEAlign
, which gives the error, the only constructor is:
CEAlign( nsArch::CHighLevelAssemblerBase* c, Cmp_unsigned__int32 size = 0 ) __QCMP_THROW;
Unless the default parameter is somehow interfering with template matching I don't see how these differ significantly.