Suppose I am allocating an arbitrary block of memory. Part of this block is atomic data (ints, bytes, etc.) and some of this block of data I want to be occupied by objects. Can I turn any arbitrary piece of memory into an object through a constructor call, such as data->MyObject ()
and subsequently destroying the object via data->~MyObject()
, or is this impossible?
Asked
Active
Viewed 540 times
1

Tony the Pony
- 40,327
- 71
- 187
- 281
-
Duplicate: http://stackoverflow.com/questions/222557/cs-placement-new – Brian R. Bondy Aug 04 '09 at 19:35
-
2It's kind of the inverse of that question, actually. That question is "I've heard of placement new, what is it?" and this one is "I want to do (description of placement new's behavior), how do I do that?" – Tyler McHenry Aug 04 '09 at 20:15