Opened 12 years ago
Last modified 12 years ago
#4359 new Bugs
boost bind doesn't work with inherited structures
| Reported by: | Owned by: | Peter Dimov | |
|---|---|---|---|
| Milestone: | Boost 1.44.0 | Component: | bind |
| Version: | Boost 1.44.0 | Severity: | Problem |
| Keywords: | Cc: |
Description
The following code gives an error in VC++2008, VC++2010, g++ 4.2.4:
#include <boost/bind.hpp>
struct Y {
void reset() {};
};
template<typename T1, typename T2>
struct my_pair {
T1 first;
T2 second;
};
template<typename T1, typename T2>
struct my_pair2 : my_pair<T1, T2> {};
typedef my_pair<int, Y> mypair_t;
typedef my_pair2<int, Y> mypair2_t;
int main()
{
mypair_t t1;
mypair2_t t2;
boost::bind<Y&>( &mypair_t::second, _1 )( t1 ).reset(); // OK!
boost::bind<Y&>( &mypair2_t::second, _1 )( t2 ).reset(); // error: cannot convert from 'const Y' to 'Y &'
return 0;
}
Note:
See TracTickets
for help on using tickets.

This is a result of mem_fn's logic for handling get_pointer. I'm somewhat hesitant to touch this, as it's rather easy to break older compilers.