Opened 8 years ago

Closed 7 years ago

#11177 closed Bugs (fixed)

signals2 does not allow reference return values for a slot

Reported by: Peter Brockamp <peter.brockamp@…> Owned by: Frank Mori Hess
Milestone: To Be Determined Component: signals2
Version: Boost 1.57.0 Severity: Problem
Keywords: slot return reference Cc:

Description

As can easily be tested it is not possible to declare a slot with a reference as a return value:

#include "boost\signals2.hpp"

void f()
{
        boost::signals2::signal<int* ()> pTest;
        boost::signals2::signal<int& ()> rTest;

        int* p = *pTest(); // OK
        //int& r = *rTest(); // C2528 on Visual Studio
}

I do understand what is causing the compiler error (pointer to reference is illegal) and that this is due to the implementation trying to store a pointer to the return value object.

Of course this could be worked around by using pointers instead of references (see above example). Nevertheless I think it would be helpful (and make a slot operate more general/generic) if a return type could also be a reference. The question is: Could this be done (didn't take an in-depth look inside the code, as usual there's a lot of macro magic and things behind the scenes)?

At least for the enduser there's no apparent reason why this should be prohibited and in case of a given library the current situation enforces additional boiler plate code. Maybe the maintainer of signals2 could give a statement about how he rates the status quo?

Thx

Peter

Change History (2)

comment:1 by Frank Mori Hess, 8 years ago

Status: newassigned

Should be fixed in the development branch now.

comment:2 by Frank Mori Hess, 7 years ago

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.