Now, when I use my original code, without the && and the std::forward<>, everything works. I've tested and I can create signals and trigger them with value types, reference types, even const reference types that can be given temporaries as the call parameter. So the original version works and does everything I want.

But it is all contrary to the expert advice I am being given, so I wondered if anyone could shed any light on the compiler error I am getting and explain what is happening here?

Thanks in advance.

0

Share this post

Link to post

Share on other sites

Now, when I use my original code, without the && and the std::forward<>, everything works. I've tested and I can create signals and trigger them with value types, reference types, even const reference types that can be given temporaries as the call parameter. So the original version works and does everything I want.

You have a different case in both examples. As has been explained in your last threads, this uses a special kind of template-deduction, called "universal references",which apply here:

Note that even if this would work, you'd probably don't want universal/rvalue references for signal/slots anyways. Since multiple things can respond to the signal there is not use for forwarding (which would mean/could lead to the first receiver of the signal moving the value of one of the attributes away). You'd just want to manually specify what you hand over in the signal: