Following is my code snippet:
struct TestPMR
{
std::vector<int> a;
std::vector<int> b;
};
I would like to use my own memory resource for vectors a
and b
. Something like a std::pmr::new_delete_resource()
. Following code is the example for what exactly I would like to implement:
auto mr = std::pmr::new_delete_resource();
std::pmr::vector<int> a(mr);
Above code works well when used within the function like:
void dummy_fn(){
auto mr = std::pmr::new_delete_resource();
std::pmr::vector<int> a(mr);
another_dummy_fn(a);
}
void another_dummy_fn(std::pmr::vector<int> v){
...
}
How can I use the same inside structure TestPMR
so that all instances of this structure allocates memory in the given memory resource? I tried std::pmr::vector<int> a(std::pmr::new_delete_resource())
and error occurs saying std::pmr::new_delete_resource() is not a type name
typedef function is not a type name? This link did not answer my question.