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.
new ((void*)SomePtr) T(NewValue);
T is a template type.
Please post your code and error you are getting
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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);
}
void push_back(const T& NewValue)
{
MakeSpaceForNew();
new ((void*)ptr+VSize) T(NewValue);
}
ASKER
>>Did you use include <new>?
No, I didn't.
Do I have to use std::new with this?
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.
Not on my compiler.