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.
CuriousGeorge916Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
AxterConnect With a Mentor Commented:
Did you use include <new>?
#include <new>
0
 
proskigCommented:
Please post your code and error you are getting
0
 
CuriousGeorge916Author Commented:
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);
}
0
 
CuriousGeorge916Author Commented:
>>Did you use include <new>?
No, I didn't.

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

Not on my compiler.
0
All Courses

From novice to tech pro — start learning today.