Solved

Use new with already allocated memory.

Posted on 2002-04-29
5
178 Views
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.
0
Comment
Question by:CuriousGeorge916
  • 2
  • 2
5 Comments
 
LVL 5

Expert Comment

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

Accepted Solution

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

Author Comment

by:CuriousGeorge916
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)
{
 MakeSpaceForNew();
 new ((void*)ptr+VSize) T(NewValue);
}
0
 

Author Comment

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

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

Expert Comment

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

Not on my compiler.
0

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