Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 190
  • 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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