Boost logo

Boost Users :

Subject: Re: [Boost-users] Boost::interprocess::string
From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2012-01-03 17:26:50


El 03/01/2012 6:44, Josmon Paul escribió:
> Hi Ion,
> I have a class whose private members are string type of data. Each time
> i will create a new instance of my class and to each instance i will set
> some string type of data to it . After this i have to push this object
> it to the vector.
> Now i have a function called write_data which will take this vector list
> as input and will iterate through each vector element and push to shared
> memory vector . Now from this shared memory i have to iterate these
> objects and i have to get the string data present in these instance.
> Right now i am declaring this string type of data as
> boost::interprocess::string and will set this data to the instance of
> the class. But it will create segmentation fault when i am accessing
> this string type of data from the object when the size of string is more
> than 10. So is there any method to increase the buffer size of
> boost::interprocess::string .?

boost::interprocess::string is a normal string (indeed, from Boost 1.48
is a typedef for boost::container::string). To put it shared memory you
will need to use a shared memory allocator: you must use
boost::interprocess::basic_string<char, std::char_traits<char>,
boost::interprocess::allocator<char> >.

To help you with more details, I would need a compilable cpp example.

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