Boost logo

Boost Users :

Subject: Re: [Boost-users] Help with custom classes PLEASE!!
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2010-02-01 16:42:21


AMDG

Daniel Veneros wrote:
> Hi, I am trying to create a shared memory segment where I can share a STRING
> between 2 process, I tried using the following code:
>
> *In the "main" process:*
>
> #include <boost/interprocess/managed_shared_memory.hpp>
> #include <boost/interprocess/containers/vector.hpp>
> #include <boost/interprocess/allocators/allocator.hpp>
> #include <cstdlib>
> #include <string>
> #include <iostream>
>
>
> using namespace boost::interprocess;
>
>
> typedef allocator<std::string, managed_shared_memory::segment_manager>
> ShMemAllocator;
>
> typedef vector<std::string, ShMemAllocator> MyVector;
>

You can't use std::string. You need to use
boost::interprocess::basic_string
with an appropriate allocator (just as you need to use
boost::interprocess::vector
instead of std::vector).

In Christ,
Steven Watanabe


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