[signals2] Connect to overloaded slots

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[signals2] Connect to overloaded slots

Boost - Users mailing list
Hello,

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?

Thanks,
Florian
_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: [signals2] Connect to overloaded slots

Boost - Users mailing list
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 mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users