I need to create a structure in shared memory. This is an example of the classes:
struct A{
std::string str1;
int val;
}
struct B{
A inner;
std::string name;
}
I could not find an example of this in the web, but after some search i was able to see that i might need to implement some allocators, and that types like string should not be used as bare, So i created an allocator for strings that looks like this:
typedef allocator<char, ip::managed_shared_memory::segment_manager> char_alloc
class String2: public ip::basic_string<char, std::char_traits<char>, char_alloc > { public:
String2(char_alloc& _all): ip::basic_string<char, std::char_traits<char>, char_alloc >(_all) {;} };
But now i have some problems trying to understand how i can create an allocator that works like this for both classes.
Does anyone have an example of something similar to this?
Thanks in advance