Boost logo

Boost Users :

Subject: Re: [Boost-users] Writing a dynamic string into a shared memory using Boost Library
From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2014-06-09 06:05:01


El 09/06/2014 1:59, Hany Assasa escribió:

> *Possible Answer:*
>
> I believe the answer to my question is, converting |std::string| into
> |my_string| type. so can anyone tell me how to do that?

my_string ms(std_string.c_str(), shm_allocator);

or

my_string ms(std_string.begin(), std_string.end(), shm_allocator);

There area many possible ways using my_string constructor. You must
always pass an allocator.

However I don't think that's your problem. Do you have internal zero
bytes in "char *data"? Just check if strlen(data) is equal to
data_to_share.size(). If you have internal zeroes, use

(data_to_share.begin(), data_to_share.end(),
managed_shm.get_segment_manager());

to build the shared memory string.

Best,

Ion


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net