Link to home
Start Free TrialLog in
Avatar of CuriousGeorge916
CuriousGeorge916

asked on

Use new with already allocated memory.

I'm trying to use new with memory that already been allocated, but I keep getting a compile error.

new ((void*)SomePtr) T(NewValue);

T is a template type.
Avatar of proskig
proskig

Please post your code and error you are getting
ASKER CERTIFIED SOLUTION
Avatar of Axter
Axter
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of CuriousGeorge916

ASKER

The complete code is to large, and the function that contains the above code I posted only has two lines of code.
void push_back(const T& NewValue)
{
 MakeSpaceForNew();
 new ((void*)ptr+VSize) T(NewValue);
}
>>Did you use include <new>?
No, I didn't.

Do I have to use std::new with this?
>>Do I have to use std::new with this?

Not on my compiler.