Opened 11 years ago

Last modified 11 years ago

#6710 new Feature Requests

Boost Containers Using interprocess Basic_strings Need external temporaries

Reported by: jdy@… Owned by: Ion Gaztañaga
Milestone: To Be Determined Component: container
Version: Boost 1.49.0 Severity: Problem
Keywords: interprocess, container, map, flat_map, unordered_map Cc: igaztanaga@…, jdy@…

Description

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

Joel

Change History (3)

comment:1 by Daniel James, 11 years ago

I'm not sure, because you haven't actually said what you want, but I think this was fixed in [58405].

comment:2 by jdy@…, 11 years ago

Feature request:

Modify the container such that code such as:

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

could instead be written as

mymap_in_shared_memory[mystring] = junk;

while avoiding the creation of a temporary as discussed above. Ion mentioned that techniques used here:

http://www.boost.org/doc/libs/1_49_0/libs/multi_index/doc/reference/ord_indices.html#set_operations

and

http://www.boost.org/doc/libs/1_49_0/doc/html/intrusive/advanced_lookups_insertions.html#intrusive.advanced_lookups_insertions.advanced_lookups

can facilitate this.

The fix in 58405 doesn't seem to address this as the code above doesn't compile. Furthermore, the docs for unordered do not discuss CompatibleTypes.

Joel

comment:3 by anonymous, 11 years ago

Also, the change set you mentioned (58405) is for unordered. This feature request is for the boost::containers. https://svn.boost.org/trac/boost/ticket/6711 is for unordered.

Thanks! Joel

Note: See TracTickets for help on using tickets.