Use new with already allocated memory.

Posted on 2002-04-29
Last Modified: 2010-04-02
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.
Question by:CuriousGeorge916
  • 2
  • 2

Expert Comment

ID: 6976942
Please post your code and error you are getting
LVL 30

Accepted Solution

Axter earned 150 total points
ID: 6976953
Did you use include <new>?
#include <new>

Author Comment

ID: 6976974
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)
 new ((void*)ptr+VSize) T(NewValue);

Author Comment

ID: 6976976
>>Did you use include <new>?
No, I didn't.

Do I have to use std::new with this?
LVL 30

Expert Comment

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

Not on my compiler.

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

930 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now