Boost interprocess: shared memory and stl types

I have a simple structure:

struct MyType
{
    std::string name;
    std::string description;
}

and I put it in shared memory:

managed_shared_memory sharedMemory(open_or_create, "name", 65535);
MyType* pType = sharedMemory.construct<MyType>("myType")();
// ... setting pType members ...

If two applications that interact with shared memory are built using a different version of Visual Studio (a different version of the stl implementation), should I put my own types in shared memory (like char *) instead of stl types?

Edit :

I tried using

typedef boost::interprocess::basic_string<char> shared_string;

and it works!

+3
source share
2 answers

Boost.Interprocess STL . std::string, , . .

+2

typedef boost::interprocess::basic_string<char> shared_string;
struct MyType
{
    shared_string name;
    shared_string description;
}
+3

Source: https://habr.com/ru/post/1715077/


All Articles