Boost logo

Boost Users :

Subject: Re: [Boost-users] Mutex synchronised wrapper class for boost::interprocess shared memory vector of strings
From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2013-06-19 16:05:32


El 18/06/2013 16:28, Riskybiz escribió:
> I'm trying to write a wrapper class in C++ to give mutex synchronised
> interprocess access to a shared memory vector of strings. This is my first
> foray into boost::interprocess and allocators are proving something of a
> mystery.
>
> Is anyone able to see why on compilation I get the error:

When you build any container in shared memory it must be constructed
with an allocator. Change your push function to (not charallocator is
passed to MyShmString):

void push(const std::string & in)
{
     CharAllocator charallocator(m_segment->get_segment_manager());
     scoped_lock<named_mutex> lock(*m_mutex);
     MyShmString inStr(in.c_str(), charallocator);
     sharedSegmentVector->push_back(inStr);
}

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