vendredi 24 juillet 2015

move C++ object to memory location

I probably will need to do something similar to what std::vector doing:

T *mem = malloc(...); // notice this is just memory allocation.
T t;
move... t to mem
mem->doSomething();

How I can move t over allocated memory?

How can I move object from allocated memory onto new variable.

How can I delete object from allocated memory - call d-tor manually?

Must I use placement new and assignment operators?

Aucun commentaire:

Enregistrer un commentaire