Re: [Boost-bugs] [Boost C++ Libraries] #12721: intrusive key_of_value requires value to be returned by reference

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #12721: intrusive key_of_value requires value to be returned by reference
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2017-01-17 00:24:13


#12721: intrusive key_of_value requires value to be returned by reference
-------------------------------+------------------------
  Reporter: mgaunard | Owner: igaztanaga
      Type: Bugs | Status: new
 Milestone: To Be Determined | Component: intrusive
   Version: Boost 1.61.0 | Severity: Problem
Resolution: | Keywords:
-------------------------------+------------------------

Comment (by fdegros@…):

 Maybe the documentation needs to be updated.

 See
 http://www.boost.org/doc/libs/1_63_0/doc/html/intrusive/map_multimap.html.
 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".

 The example also emphasizes that a reference must be returned. This could
 be updated, especially since the example function returns an {{{int}}}.

 Example:

 {{{
 // 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&" and
 // returning "type" or "const type &"
 struct first_int_is_key
 {
    typedef int type;

    type operator()(const MyClass& v) const { return v.first; }
 };
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/12721#comment:2>
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:20 UTC