So I want to implement a method like C++11's emplace_back in std vector for a memorypool class that I'm implementing. The idea is that I have a typename T of my memorypool and when the user calls emplace_back, he passes and calls the constructor of T on a memory region I got. I'm not sure how this can be done as it seems to use some inner features of c++ which I'm not aware of. Anyone has a clue?
Asked
Active
Viewed 111 times
0
-
1Look up placement new. – NathanOliver Aug 07 '18 at 13:45
-
1Probably relevant https://cpppatterns.com/patterns/perfect-forwarding.html – Slava Aug 07 '18 at 13:49
-
2Don't take it as a personal slight that this question has been closed as a duplicate. Finding the right words to search for is hard if you don't know the answer. SO leaves duplicates up as a signpost for other people to the canonical question and its answer. – Martin Bonner supports Monica Aug 07 '18 at 13:52