To save some code lets say I have a custom allocator named MyAlloc
which I have successfully used with a std::vector<int>
as follows:
std::vector<int,MyAlloc<int>> vec;
now I want to save a lambda in a std::function using the custom allocator, how do I do it?
My failed attempt:
int i[100];
std::function<void(int)> f(MyAlloc<void/*what to put here?*/>{},[i](int in){
//...
});
Update: allocators in std::function have been deprecated
See Question&Answers more detail:os