[Boost-bugs] [Boost C++ Libraries] #6711: with unordered_map using interprocess basic_string in shared memory, find and [] are annoying

Subject: [Boost-bugs] [Boost C++ Libraries] #6711: with unordered_map using interprocess basic_string in shared memory, find and [] are annoying
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-03-20 00:26:46


#6711: with unordered_map using interprocess basic_string in shared memory, find
and [] are annoying
---------------------------------+------------------------------------------
 Reporter: jdy@… | Type: Feature Requests
   Status: new | Milestone: To Be Determined
Component: None | Version: Boost 1.49.0
 Severity: Problem | Keywords: interprocess, unordered_map, container
---------------------------------+------------------------------------------
 When using an interprocess basic string such as:

 {{{
 typedef boost::interprocess::allocator<
         char,
         boost::interprocess::managed_mapped_file::segment_manager
> char_allocator_t;

 typedef boost::interprocess::basic_string<
         char,
         std::char_traits<char>,
         char_allocator_t
> key_type;
 }}}


 map, flat_map (and unordered_map) all require that one have an externally
 created temporary of that type (key_type) created that can temporarily
 hold the results of a std::string or char*. This requires code of the
 form:


 {{{
       // A temporary string that allocates from the mapped file
       struct shm_clean { // cleanup shared memory on stack-unwind
         shm_clean() {
 boost::interprocess::shared_memory_object::remove("StupidSharedMemory");
         }
         ~shm_clean() {
 boost::interprocess::shared_memory_object::remove("StupidSharedMemory");
         }
       } cleaner;
       boost::interprocess::managed_shared_memory
 stupid(boost::interprocess::create_only ,"StupidSharedMemory" ,500);
       key_type key_val(stupid.get_segment_manager());

 mymap_in_shared_memory[key_val = mystring.c_str()] = junk;
 }}}


 This is barely ok when we are working with mutable memory regions, but
 when I am working in a read-only memory map, it is annoying.

 Please see this thread:

 http://thread.gmane.org/gmane.comp.lib.boost.devel/228874

 Bug posted at request of Ion Gaztañaga

 See sister ticked for boost::containers

 https://svn.boost.org/trac/boost/ticket/6710

 Joel

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/6711>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:09 UTC