Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 187
  • Last Modified:

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.
0
CuriousGeorge916
Asked:
CuriousGeorge916
  • 2
  • 2
1 Solution
 
proskigCommented:
Please post your code and error you are getting
0
 
AxterCommented:
Did you use include <new>?
#include <new>
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

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now