Re: [Boost-bugs] [Boost C++ Libraries] #5342: find_ptr (find wrapper)

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #5342: find_ptr (find wrapper)
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-10-07 13:17:19


#5342: find_ptr (find wrapper)
-----------------------------------+----------------------------------------
  Reporter: olafvdspek@… | Owner: nesotto
      Type: Feature Requests | Status: new
 Milestone: Boost 1.47.0 | Component: ptr_container
   Version: Boost 1.46.0 | Severity: Problem
Resolution: | Keywords:
-----------------------------------+----------------------------------------

Comment (by Olaf van der Spek <olafvdspek@…>):

 You're right, this can be done with non-member functions:
 {{{

 template <class T, class U>
 typename T::value_type::second_type* find_ptr(T& c, U v)
 {
         typename T::iterator i = c.find(v);
         return i == c.end() ? NULL : &i->second;
 }

 template <class T, class U>
 const typename T::value_type::second_type* find_ptr(const T& c, U v)
 {
         typename T::const_iterator i = c.find(v);
         return i == c.end() ? NULL : &i->second;
 }

 template <class T, class U>
 typename T::value_type::second_type find_ptr2(T& c, U v)
 {
         typename T::iterator i = c.find(v);
         return i == c.end() ? NULL : i->second;
 }

 template <class T, class U>
 const typename T::value_type::second_type find_ptr2(const T& c, U v)
 {
         typename T::const_iterator i = c.find(v);
         return i == c.end() ? NULL : i->second;
 }
 }}}

 Now the hard part is to find a Boost lib that'd like to adopt these
 functions.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/5342#comment:4>
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:07 UTC