How do I work around this problem with bind? #include <boost/bind.hpp> namespace { class functions { public: int func( int ); int func( int, int ); }; void test() { functions a_func; boost::bind( functions::func, a_func, 1, _1 ); } } Bind can't determine which function to call because it is overloaded and it doesn't know the context in which it will be called. With CodeWarrior 8 on Mac OS X I get "illegal use of template argument dependent type 'T::result_type' It references an "unspecified" template deep in the bowels of bind. As I recall there was some way of helping bind to pick one of the overloaded functions using a typedef or something similar. (Maybe that was function?). Thanks for any tips, ...Duane
Duane Murphy wrote:
How do I work around this problem with bind?
#include <boost/bind.hpp>
namespace {
class functions { public: int func( int ); int func( int, int ); };
void test() { functions a_func;
boost::bind( functions::func, a_func, 1, _1 ); }
}
This looks like it should work (after adding an ampersand in front of functions::func) .... Works of VC7.1 and GCC 3.4.2.
As I recall there was some way of helping bind to pick one of the overloaded functions using a typedef or something similar. (Maybe that was function?).
See this thread. http://lists.boost.org/MailArchives/boost/msg69451.php This message has an example almost the same as yours: http://lists.boost.org/MailArchives/boost/msg69561.php
Thanks for any tips,
...Duane
Jonathan
--- At Thu, 27 Jan 2005 18:31:22 -0700, Jonathan Turkanis wrote:
Duane Murphy wrote:
How do I work around this problem with bind?
#include <boost/bind.hpp>
namespace {
class functions { public: int func( int ); int func( int, int ); };
void test() { functions a_func;
boost::bind( functions::func, a_func, 1, _1 ); }
}
This looks like it should work (after adding an ampersand in front of functions::func) .... Works of VC7.1 and GCC 3.4.2.
As I recall there was some way of helping bind to pick one of the overloaded functions using a typedef or something similar. (Maybe that was function?).
See this thread.
http://lists.boost.org/MailArchives/boost/msg69451.php
This message has an example almost the same as yours:
Thanks! That's what I needed to give me the solution. #include <boost/bind.hpp> namespace { class functions { public: int func( int ) const; void test() const; protected: int func( int, int ) const; }; void functions::test() const { int (functions::* func_1)( int, int ) const = &functions::func; boost::bind( func_1, *this, 1, _1 ); } } This is a much more like what I was battling. (Thanks for reminding me about the list archives as well.) ...Duane
participants (2)
-
Duane Murphy
-
Jonathan Turkanis