trouble with bind+signals

I'm relatively new to the boost library and I'm having a problem with boost::signals and bind. I've reproduced the problem I'm hitting here. c++: typedef boost::signal <LRESULT (ISigSource &, LPCREATESTRUCT)> SigWMCreate; SigWMCreate sig; LPARAM x; boost::bind(boost::ref(sig), boost::ref(*this), _1)((LPCREATESTRUCT)(x)); The above function application generates the following warning on msvc 8/vs2005: Error 1 error C2664: '__w64 long boost::_bi::bind_t<R,F,L>::operator ()<LPCREATESTRUCT>(A1 &) const' : cannot convert parameter 1 from 'LPCREATESTRUCT' to 'LPCREATESTRUCT &' c:\documents and settings\catphive\my documents\visual studio 2005\projects\game\game\mainfrm.cpp 20 Now, this problem goes away if x is of type LPCREATESTRUCT to start with instead of another type converted to LPCREATESTRUCT within the parentheses of the function application. This seems a bit odd to me. Also, I'd like to avoid changing how the function application is performed and get to the root of the problem since in my *actual* code, the application is performed in a system macro, and I'd like to avoid changing external headers (and having to remember what I changed in case of an update to the headers) if possible. My guess is that performing the cast creates an intermediary result that I'm not allowed to take a reference of. Is this the case? Does this happen on other compilers with analogous types? Is there a way to work around this? Thanks

Brendan Miller wrote:
I'm relatively new to the boost library and I'm having a problem with boost::signals and bind. I've reproduced the problem I'm hitting here.
c++: typedef boost::signal <LRESULT (ISigSource &, LPCREATESTRUCT)> SigWMCreate; SigWMCreate sig; LPARAM x;
boost::bind(boost::ref(sig), boost::ref(*this), _1)((LPCREATESTRUCT)(x));
[...]
My guess is that performing the cast creates an intermediary result that I'm not allowed to take a reference of. Is this the case?
You are right. A fix for this problem is available in the 1.34 branch and will be part of the next release; in the meantime, you can try replacing boost/bind/bind_template.hpp with this version: http://boost.cvs.sourceforge.net/boost/boost/boost/bind/bind_template.hpp?revision=1.7&view=markup and see whether this helps.

Thanks, the new header fixed my problem. On 7/9/06, Peter Dimov <pdimov@mmltd.net> wrote:
Brendan Miller wrote:
I'm relatively new to the boost library and I'm having a problem with boost::signals and bind. I've reproduced the problem I'm hitting here.
c++: typedef boost::signal <LRESULT (ISigSource &, LPCREATESTRUCT)> SigWMCreate; SigWMCreate sig; LPARAM x;
boost::bind(boost::ref(sig), boost::ref(*this), _1)((LPCREATESTRUCT)(x));
[...]
My guess is that performing the cast creates an intermediary result that I'm not allowed to take a reference of. Is this the case?
You are right. A fix for this problem is available in the 1.34 branch and will be part of the next release; in the meantime, you can try replacing boost/bind/bind_template.hpp with this version:
http://boost.cvs.sourceforge.net/boost/boost/boost/bind/bind_template.hpp?revision=1.7&view=markup
and see whether this helps.
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
Brendan Miller
-
Peter Dimov