Boost logo

Boost Users :

Subject: Re: [Boost-users] Initialising boost::interprocess::basic_string using std::string
From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2010-03-18 21:49:00


El 18/03/2010 18:17, med ennemri escribió:
> Hi all
> How to initialising boost::interprocess::basic_string using std::string;

Use this constructor passing std::string::c_str() (and don't forget the
allocator, interprocess containers need always a valid allocator to
allocate memory in shared memory):

    basic_string(const CharT* s,
                 const allocator_type& a = allocator_type())

typedef /*...*/ interprocess_string_t;

interprocess_string_t * =
  managed_shm.construct<interprocess_string_t>("name")
    (std_str.c_str(), managed_shm.get_allocator<char>());

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