Boost C++ Libraries: Ticket #12721: intrusive key_of_value requires value to be returned by reference https://svn.boost.org/trac10/ticket/12721 <p> key_of_value requires the key to be returned by reference, this is an unnecessary limitation and prevents using types which return the key by value through an accessor. If the type is returned by value, one will get a warning about returning a reference to a local variable. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/12721 Trac 1.4.3 Ion Gaztañaga Mon, 16 Jan 2017 00:28:27 GMT <link>https://svn.boost.org/trac10/ticket/12721#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12721#comment:1</guid> <description> <p> This should have been fixed in Boost 1.62. See ticket 11994 for details: </p> <p> <a class="ext-link" href="https://svn.boost.org/trac/boost/ticket/11994"><span class="icon">​</span>https://svn.boost.org/trac/boost/ticket/11994</a> </p> </description> <category>Ticket</category> </item> <item> <author>fdegros@…</author> <pubDate>Tue, 17 Jan 2017 00:24:13 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/12721#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12721#comment:2</guid> <description> <p> Maybe the documentation needs to be updated. </p> <p> See <a href="http://www.boost.org/doc/libs/1_63_0/doc/html/intrusive/map_multimap.html">http://www.boost.org/doc/libs/1_63_0/doc/html/intrusive/map_multimap.html</a>. It still specifies that the key extractor must have a "member function to obtain a const reference to the key stored inside a value_type". </p> <p> The example also emphasizes that a reference must be returned. This could be updated, especially since the example function returns an <code>int</code>. </p> <p> Example: </p> <pre class="wiki">// key_of_value function object, must: // - be default constructible (and lightweight) // - define the key type by defining a nested type called "type" // - define an operator() taking "const value_type&amp;" and // returning "type" or "const type &amp;" struct first_int_is_key { typedef int type; type operator()(const MyClass&amp; v) const { return v.first; } }; </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>Ion Gaztañaga</dc:creator> <pubDate>Mon, 06 Feb 2017 12:21:43 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/12721#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12721#comment:3</guid> <description> <p> Thanks. Documentation fixed in commit: </p> <p> <a class="ext-link" href="https://github.com/boostorg/intrusive/commit/6fe118157867ea26109447ad5eeaaa02fb2dce57"><span class="icon">​</span>https://github.com/boostorg/intrusive/commit/6fe118157867ea26109447ad5eeaaa02fb2dce57</a> </p> </description> <category>Ticket</category> </item> </channel> </rss>