Opened 10 years ago

Closed 9 years ago

#8406 closed Bugs (invalid)

boost::_bi::result_traits should handle function pointers

Reported by: jason@… Owned by: Peter Dimov
Milestone: To Be Determined Component: bind
Version: Boost Development Trunk Severity: Problem
Keywords: Cc:

Description

I recently modified G++ to enforce the rule that forming a function type with an abstract class as a return or parameter type causes a substitution failure. So now we instantiate return/parameter types during substitution in order to check whether they are abstract. I've gotten a bug report (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56838) that this breaks boost/bind; a trivial example like

#include <boost/bind.hpp>
void f();
int main() { boost::bind(&f); }

causes an error because while forming overload candidates we end up trying to instantiate result_traits<unspecified, void(*)()>, which fails.

It seems to me that instead of (or in addition to) all the overloads of bind in bind_cc.hpp, there should be partial specializations of result_traits to deal with function pointers; then the generic function object overload would handle them. That is, specializations like

template<class R>
struct result_traits<unspecified, BOOST_BIND_ST R (BOOST_BIND_CC *)()>
{
  typedef R type;
}

The committee may well decide that the G++ behavior is wrong and we should adjust the standard accordingly, but it still seems that this would be an improvement to boost.

Change History (2)

comment:1 by Peter Dimov, 10 years ago

The generic overload can't perform overload resolution. If you have

void f( int );
void f( int, int );

then boost::bind( f, 1 ) works and selects the first overload. This is not supported by std::bind but existing code that uses boost::bind relies on it.

comment:2 by Peter Dimov, 9 years ago

Resolution: invalid
Status: newclosed
Note: See TracTickets for help on using tickets.