roshambo
March 8th, 2008, 12:41 PM
I'm trying to explicitly construct an object with operator new. I've searched and wrote the following code.
template <class T> T *Alloc()
{
char *x = (char *)malloc(sizeof(T));
T* ret = ::new(x) T();
return (T *)x;
}
Compiling this in Visual Studio (2005) gives the following error:
error C2660: 'operator new' : function does not take 2 arguments
While I know what this error means, it seems it does work, just not on my compiler. Is there a MVS 2005 version?
template <class T> T *Alloc()
{
char *x = (char *)malloc(sizeof(T));
T* ret = ::new(x) T();
return (T *)x;
}
Compiling this in Visual Studio (2005) gives the following error:
error C2660: 'operator new' : function does not take 2 arguments
While I know what this error means, it seems it does work, just not on my compiler. Is there a MVS 2005 version?