$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
From: Marc Viala (mviala_at_[hidden])
Date: 2006-01-23 02:53:33
Hi,
I would like to know how I can use boost::bind with template function
member? 
To explain my problem, you will find hereafter an example code that
demonstrates it. In this code, when we try to bind the function member
X::g the compiler failed with tons of error message. 
Am I doing something wrong?
Best regards,
Marc Viala
mailto:mviala_at_[hidden]
-----------------------------------
Platform:
VC++ 7.1
Boost 1.33.1
-----------------------------------
#include <boost/bind.hpp>
#include <boost/function.hpp>
struct X {
  template<typename A, typename B> 
    void g(A& a, B& b)
  { std::cout << a << " " << b << '\n' ; }
  void
    f(int& i) 
  { std::cout << i << '\n'; }
} ;
template<typename A, typename B> 
  void e(A& a, B& b)
{ std::cout << a << " " << b << '\n' ; }
int
main(int argc, char* argv[])
{
  int a = 10, b = 11 ;
  X x ;
  boost::function<void (void)> pe = boost::bind(&e<int,int>, a, b) ;
// <- OK
  pe() ;
  boost::function<void (void)> pg = boost::bind(&X::g<int,int>, &x, a,
b) ; // <- Don't compile?
  pg() ;
  boost::function<void (void)> pf = boost::bind(&X::f, &x, a) ;
// <- OK
  pf() ;
 }