Boost C++ Libraries: Ticket #6710: Boost Containers Using interprocess Basic_strings Need external temporaries https://svn.boost.org/trac10/ticket/6710 <p> When using an interprocess basic string such as: typedef boost::interprocess::allocator&lt; </p> <blockquote> <p> char, boost::interprocess::managed_mapped_file::segment_manager </p> <blockquote class="citation"> <blockquote> <p> char_allocator_t; </p> </blockquote> </blockquote> </blockquote> <p> typedef boost::interprocess::basic_string&lt; </p> <blockquote> <p> char, std::char_traits&lt;char&gt;, char_allocator_t </p> <blockquote class="citation"> <blockquote> <p> key_type; </p> </blockquote> </blockquote> </blockquote> <p> 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: </p> <blockquote> <p> <em> A temporary string that allocates from the mapped file struct shm_clean { </em> cleanup shared memory on stack-unwind </p> <blockquote> <p> shm_clean() { </p> <blockquote> <p> boost::interprocess::shared_memory_object::remove("<a class="missing wiki">StupidSharedMemory</a>"); </p> </blockquote> <p> } ~shm_clean() { </p> <blockquote> <p> boost::interprocess::shared_memory_object::remove("<a class="missing wiki">StupidSharedMemory</a>"); </p> </blockquote> <p> } </p> </blockquote> <p> } cleaner; boost::interprocess::managed_shared_memory </p> </blockquote> <p> stupid(boost::interprocess::create_only ,"<a class="missing wiki">StupidSharedMemory</a>" ,500); </p> <blockquote> <p> key_type key_val(stupid.get_segment_manager()); </p> </blockquote> <p> mymap_in_shared_memory[key_val = mystring.c_str()] = junk; </p> <p> 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. </p> <p> Please see this thread: </p> <p> <a class="ext-link" href="http://thread.gmane.org/gmane.comp.lib.boost.devel/228874"><span class="icon">​</span>http://thread.gmane.org/gmane.comp.lib.boost.devel/228874</a> </p> <p> Bug posted at request of Ion Gaztañaga </p> <p> Joel </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6710 Trac 1.4.3 Daniel James Tue, 20 Mar 2012 07:12:36 GMT <link>https://svn.boost.org/trac10/ticket/6710#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6710#comment:1</guid> <description> <p> I'm not sure, because you haven't actually said what you want, but I think this was fixed in <a class="changeset" href="https://svn.boost.org/trac10/changeset/58405" title="Add templated find overload for compatible keys.">[58405]</a>. </p> </description> <category>Ticket</category> </item> <item> <author>jdy@…</author> <pubDate>Wed, 21 Mar 2012 20:50:16 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6710#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6710#comment:2</guid> <description> <p> Feature request: </p> <p> Modify the container such that code such as: </p> <pre class="wiki">mymap_in_shared_memory[key_val = mystring.c_str()] = junk; </pre><p> could instead be written as </p> <pre class="wiki">mymap_in_shared_memory[mystring] = junk; </pre><p> while avoiding the creation of a temporary as discussed above. Ion mentioned that techniques used here: </p> <p> <a href="http://www.boost.org/doc/libs/1_49_0/libs/multi_index/doc/reference/ord_indices.html#set_operations">http://www.boost.org/doc/libs/1_49_0/libs/multi_index/doc/reference/ord_indices.html#set_operations</a> </p> <p> and </p> <p> <a href="http://www.boost.org/doc/libs/1_49_0/doc/html/intrusive/advanced_lookups_insertions.html#intrusive.advanced_lookups_insertions.advanced_lookups">http://www.boost.org/doc/libs/1_49_0/doc/html/intrusive/advanced_lookups_insertions.html#intrusive.advanced_lookups_insertions.advanced_lookups</a> </p> <p> can facilitate this. </p> <p> 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 <a class="missing wiki">CompatibleTypes</a>. </p> <p> Joel </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Wed, 21 Mar 2012 20:53:33 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6710#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6710#comment:3</guid> <description> <p> Also, the change set you mentioned (58405) is for unordered. This feature request is for the boost::containers. <a class="ext-link" href="https://svn.boost.org/trac/boost/ticket/6711"><span class="icon">​</span>https://svn.boost.org/trac/boost/ticket/6711</a> is for unordered. </p> <p> Thanks! Joel </p> </description> <category>Ticket</category> </item> </channel> </rss>