Boost logo

Boost Users :

From: Lars Monecke (lars_at_[hidden])
Date: 2006-06-26 07:52:24


Hi,

i'm stucked and google does not lead me to the right pages :-(

The follwing code example does not compile on gcc 4.1.1 an boost 1.33.1 . It
works on msvc.net 7.1.

---code starts here
#include <boost/bind.hpp>
#include <boost/signal.hpp>

#include <iostream>

struct Printer
{
  void operator()(int iValue) {
    std::cout << iValue << "\n";
  }
};

  
int main(int /* argc */, char* /* argv[] */)
{

  typedef boost::signal<void (int)> tSignal;

  tSignal stSignal;

  Printer stPrinter;
  
  stSignal.connect(stPrinter);
  
  typedef std::vector<int> tConInts;

  tConInts cInts;

  cInts.push_back(1);
  cInts.push_back(2);
  cInts.push_back(3);

  for_each(cInts.begin(),
           cInts.end(),
           boost::bind(&tSignal::operator(),
                       boost::ref(stSignal),
                       _1));

  return 0;
}
---code ends here

---gcc output starts here
main.cpp: In function 'int main(int, char*)':
main.cpp:37: error: call of overloaded 'bind(<unresolved overloaded function
type>, const boost::reference_wrapper<boost::signal<void ()(int),
boost::last_value<void>, int, std::less<int>, boost::function<void ()(int),
std::allocator<void> > > >, boost::arg<1>&)' is ambiguous
/usr/local/gcc-4.1.1/boost-1.33.1/boost/bind/bind_mf_cc.hpp:43: note:
candidates are: boost::_bi::bind_t<R, boost::_mfi::mf1<R, T, A1>, typename
boost::_bi::list_av_2<A1, A2>::type> boost::bind(R (T::*)(B1), A1, A2)
[with R = boost::last_value<void>::unusable, T = boost::signal1<void, int,
boost::last_value<void>, int, std::less<int>, boost::function<void ()(int),
std::allocator<void> > >, B1 = int, A1 =
boost::reference_wrapper<boost::signal<void ()(int),
boost::last_value<void>, int, std::less<int>, boost::function<void ()(int),
std::allocator<void> > > >, A2 = boost::arg<1>]
/usr/local/gcc-4.1.1/boost-1.33.1/boost/bind/bind_mf_cc.hpp:54: note:
boost::_bi::bind_t<R, boost::_mfi::cmf1<R, T, A1>, typename
boost::_bi::list_av_2<A1, A2>::type> boost::bind(R (T::*)(B1)const, A1, A2)
[with R = boost::last_value<void>::unusable, T = boost::signal1<void, int,
boost::last_value<void>, int, std::less<int>, boost::function<void ()(int),
std::allocator<void> > >, B1 = int, A1 =
boost::reference_wrapper<boost::signal<void ()(int),
boost::last_value<void>, int, std::less<int>, boost::function<void ()(int),
std::allocator<void> > > >, A2 = boost::arg<1>]
make: *** [main.o] Error 1
---gcc output ends here

I think something with static_cast is the solultion, but i don't know how?

Any hints?

Thanks in advance,

Lars


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