Opened 14 years ago

Closed 14 years ago

#2849 closed Bugs (fixed)

function_equal should work with binds holding weak_ptr values

Reported by: Gareth Sylvester-Bradley <gareth.sylvester-bradley@…> Owned by: Peter Dimov
Milestone: Boost 1.39.0 Component: bind
Version: Boost 1.35.0 Severity: Problem
Keywords: Cc:

Description

http://lists.boost.org/Archives/boost/2008/07/139970.php

To fix the compiler error in the program below, please can we add the following (e.g. to boost/bind.hpp) -

#include <boost/weak_ptr.hpp>

namespace boost
{
  namespace _bi
  {
    template<class T> bool ref_compare( value< weak_ptr<T> >
const & a, value< weak_ptr<T> > const & b, long )
    {
      return !(a.get() < b.get()) && !(b.get() < a.get());
    }
  }
} 

-- main.cpp --

#include <boost/function_equal.hpp>
#include <boost/bind.hpp>
#include <boost/weak_ptr.hpp>

int h( boost::weak_ptr<void> wp ) { return wp.use_count(); }

template < typename F > bool self_equal( F f_ )
{
  return function_equal( f_, f_ );
}

int main( int argc, char * const argv[] )
{
  self_equal( boost::bind( h, _1 ) ); // OK
  self_equal( boost::bind( h, boost::weak_ptr<void>() ) ); // compiler
error
  return 0;
}

Change History (3)

comment:1 by Peter Dimov, 14 years ago

Status: newassigned

comment:2 by Peter Dimov, 14 years ago

(In [51979]) Add ref_compare for weak_ptr. Refs #2849.

comment:3 by Peter Dimov, 14 years ago

Resolution: fixed
Status: assignedclosed

(In [52041]) Merge [51979] to release. Closes #2849.

Note: See TracTickets for help on using tickets.