Solved

Use new with already allocated memory.

Posted on 2002-04-29
5
177 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
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 …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
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.

746 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

13 Experts available now in Live!

Get 1:1 Help Now