Boost logo

Boost Users :

Subject: [Boost-users] Trouble with template on boost::function and boost::bind
From: pwx (airyai_at_[hidden])
Date: 2012-03-11 03:56:06


I tried to create a template function that receives boost::function as
parameter. Say like this:

template <typename T1, typename T2>
void proc(const boost::function<void(const T1&, T2&)> &p) {
// ...
}

void f(const string& s1, string&s2) {
// ...
}

Everything goes ok when I called proc( boost::function<void(const
string&, string&)>(f) ). But when I try this:

proc(boost::bind(f, _1, _2));

The compiler refused with the error:

no matching function for call to
‘proc(boost::_bi::bind_t<boost::_bi::unspecified, F,
boost::_bi::list2<boost::arg<1>, boost::arg<2> > >)’

Anyway to fulfill this design purpose? Thanks.


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