Opened 10 years ago
Closed 9 years ago
#8406 closed Bugs (invalid)
boost::_bi::result_traits should handle function pointers
Reported by: | 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 , 10 years ago
comment:2 by , 9 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
The generic overload can't perform overload resolution. If you have
then
boost::bind( f, 1 )
works and selects the first overload. This is not supported bystd::bind
but existing code that usesboost::bind
relies on it.