Context: Writing a container containing type T and char * p to the memory area. Suppose the pointer is already properly aligned for type T - the alignment problem is not part of the question. How do I build an element in this memory area by default?
((*T)(p))->T();
works for classes, but not with some built-in types.
((*T)(p)) = 0;
for integer types, pointers. Do these two cover everything, alliances, and what not? Is there any best practice for this or some kind of standard library function? std :: allocator :: construct can do this, that is, for example, std :: vector uses, but this is not a static method, so I need an instance of it. Is there some kind of standalone or static function that can do this?
- EDIT -
Yes, the answer is obvious, and today I was dumb - posting a new BTW, now I'm trying to destroy an element ...
source
share