|
Boost Users : |
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2008-07-07 19:32:22
AMDG
James Sutherland wrote:
> This gives an error:
> invalid static_cast from type <unknown type> to type int
> (X::*)(int)
> Any other ideas?
What compiler are you using? The following
compiles for me with msvc 9.0, gcc 3.4.4 and gcc 4.3.0
#include <boost/function.hpp>
#include <boost/bind.hpp>
#include <functional>
#include <iostream>
struct X {
int foo(int i) { return ++i; }
template<class T> void foo( T& t );
};
int main()
{
boost::function<int(int)> f;
X x;
f = boost::bind(static_cast<int(X::*)(int)>(&X::foo), &x, _1);
std::cout << f(5) << std::endl;
}
In Christ,
Steven Watanabe
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net