Boost logo

Boost Users :

Subject: Re: [Boost-users] [signals2] Connect to overloaded slots
From: niXman (i.nixman_at_[hidden])
Date: 2017-11-10 12:58:07


Florian Lindner via Boost-users писал 2017-11-10 15:54:
> Hello,

Hi,
> this code compiles just fine:
>
> #include <boost/signals2.hpp>
> #include <iostream>
>
> // void slot() { std::cout << "No args slot called." << std::endl; }
> void slot(int i) { std::cout << "Int " << i << " arg slot called." <<
> std::endl; }
>
> int main(int argc, char **argv)
> {
> boost::signals2::signal<void(int)> s;
> s.connect(&slot);
>
> return 0;
> }
>
> However, when I uncomment the slot() function, it does not do so,
> anymore:
>
>
> boostsignals.cpp:78:5: error: no matching member function for call to
> 'connect'
> s.connect(&slot);
> ~~^~~~~~~
> /usr/include/boost/signals2/detail/signal_template.hpp:689:18: note:
> candidate function not viable: no overload of
> 'slot' matching 'const boost::signals2::signal<void (int),
> boost::signals2::optional_last_value<void>, int,
> std::less<int>, boost::function<void (int)>,
> boost::function<void (const boost::signals2::connection &, int)>,
> boost::signals2::mutex>::slot_type' (aka 'const slot<void (int),
> boost::function<void (int)> >') for 1st argument
> connection connect(const slot_type &slot, connect_position
> position = at_back)
> ^
> /usr/include/boost/signals2/detail/signal_template.hpp:693:18: note:
> candidate function not viable: requires at least 2
> arguments, but 1 was provided
> connection connect(const group_type &group,
> ^
>
> Is there a way to make it working with overloaded slot functions?

Because:
https://stackoverflow.com/questions/14279874/how-to-use-static-cast-to-resovle-overloaded-functions

-- 
Regards, niXman
___________________________________________________
Work for Bitcoins
___________________________________________________
Dual-target(32 & 64-bit) MinGW-W64 compilers for 32 and 64-bit Windows:
https://sf.net/p/mingw-w64/

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