Boost interprocess: cout a string variable when iterating through a map that references an object from a struct

后端 未结 3 935
孤街浪徒
孤街浪徒 2021-01-18 19:23

I\'m using boost::interprocess to share objects between processes. I have two files, a \"server.cpp\" that generates a struct object and passes the object into a map with an

3条回答
  •  伪装坚强ぢ
    2021-01-18 19:37

    Some great info from previous posters led me to a simple answer of my own. Use a char array in the struct, then read it into a string as follows:

    std::cout<first<<" "<second.ORDERTYPE<<" "<second.MYID)<<"\n";
    

    here is the struct I speak of:

    struct order {
        char MYID[100];
        int ORDERTYPE;
        char DATE_UPDATED[64];
    };
    order o
    

    here is how i passed the struct into memory:

    m_pmap->insert(std::pair(i, (order)o));
    

    now i am able to write a map of structs containing various types including strings, to memory, and retrieve them from memory.

提交回复
热议问题