[signals] unresolved overloaded function type with gcc 4.1
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
On Mon, 26 Jun 2006 13:52:24 +0200, Lars Monecke <lars@monecke.de> wrote:
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
Any hints? Doesn't something like for_each(...,...,bind(stSignal,_1));
work? (Maybe with bind<Ret>(), see docs) Regards Jiri Palecek -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Jiri Palecek wrote:
Doesn't something like for_each(...,...,bind(stSignal,_1));
work?
::signal1(const boost::signal1<void, int, boost::last_value<void>, int, std::less<int>, boost::function<void ()(int), std::allocator<void> > >&)': /usr/local/gcc-4.1.1/boost-1.33.1/boost/signals/signal_template.hpp:142: note: synthesized method 'boost::boost_signals::detail::signal_base::signal_base(const boost::boost_signals::detail::signal_base&)' first required here /usr/local/gcc-4.1.1/boost-1.33.1/boost/signal.hpp: In copy constructor 'boost::signal<void ()(int), boost::last_value<void>, int, std::less<int>, boost::function<void ()(int), std::allocator<void> > >::signal(const boost::signal<void ()(int), boost::last_value<void>, int, std::less<int>, boost::function<void ()(int), std::allocator<void> > >&)': /usr/local/gcc-4.1.1/boost-1.33.1/boost/signal.hpp:333: note: synthesized method 'boost::signal1<void, int, boost::last_value<void>, int, std::less<int>, boost::function<void ()(int), std::allocator<void> > ::signal1(const boost::signal1<void, int, boost::last_value<void>, int, std::less<int>, boost::function<void ()(int), std::allocator<void> > >&)' first required here
Sorry, no: /usr/local/gcc-4.1.1/boost-1.33.1/boost/noncopyable.hpp: In copy constructor 'boost::boost_signals::detail::signal_base::signal_base(const boost::boost_signals::detail::signal_base&)': /usr/local/gcc-4.1.1/boost-1.33.1/boost/noncopyable.hpp:27: error: 'boost::noncopyable_::noncopyable::noncopyable(const boost::noncopyable_::noncopyable&)' is private /usr/local/gcc-4.1.1/boost-1.33.1/boost/signals/detail/signal_base.hpp:119: error: within this context /usr/local/gcc-4.1.1/boost-1.33.1/boost/signals/signal_template.hpp: In copy constructor 'boost::signal1<void, int, boost::last_value<void>, int, std::less<int>, boost::function<void ()(int), std::allocator<void> > main.cpp: In function 'int main(int, char*)': main.cpp:41: note: synthesized method 'boost::signal<void ()(int), boost::last_value<void>, int, std::less<int>, boost::function<void ()(int), std::allocator<void> > >::signal(const boost::signal<void ()(int), boost::last_value<void>, int, std::less<int>, boost::function<void ()(int), std::allocator<void> > >&)' first required here main.cpp:41: error: initializing argument 1 of 'boost::_bi::bind_t<boost::_bi::unspecified, F, typename boost::_bi::list_av_1<A1>::type> boost::bind(F, A1) [with F = boost::signal<void ()(int), boost::last_value<void>, int, std::less<int>, boost::function<void ()(int), std::allocator<void> > >, A1 = boost::arg<1>]' More hints? Thanks, Lars -- Lars Monecke http://www.monecke.de PGP-Key unter https://www.monecke.de/infos/monecke.asc
Jiri Palecek wrote:
On Mon, 26 Jun 2006 13:52:24 +0200, Lars Monecke <lars@monecke.de> wrote:
[...]
for_each(cInts.begin(), cInts.end(), boost::bind(&tSignal::operator(), boost::ref(stSignal), _1));
return 0; } ---code ends here
Any hints? Doesn't something like for_each(...,...,bind(stSignal,_1));
work?
Signals are noncopyable, but for_each( cInts.begin(), cInts.end(), boost::bind( boost::ref( stSignal ), _1 ) ); should work.
Peter Dimov wrote:
for_each( cInts.begin(), cInts.end(), boost::bind( boost::ref( stSignal ), _1 ) );
should work.
Yes. Thank You, Best Regards Lars -- Lars Monecke http://www.monecke.de PGP-Key unter https://www.monecke.de/infos/monecke.asc
participants (3)
-
Jiri Palecek
-
Lars Monecke
-
Peter Dimov