[Boost-bugs] [Boost C++ Libraries] #11177: signals2 does not allow reference return values for a slot

Subject: [Boost-bugs] [Boost C++ Libraries] #11177: signals2 does not allow reference return values for a slot
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-04-09 10:32:21


#11177: signals2 does not allow reference return values for a slot
-----------------------------------------------+----------------------
 Reporter: Peter Brockamp <peter.brockamp@…> | Owner: fmhess
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: signals2
  Version: Boost 1.57.0 | Severity: Problem
 Keywords: slot return reference |
-----------------------------------------------+----------------------
 As can easily be tested it is not possible to declare a slot with a
 reference as a return value:

 {{{
 #!cpp
 #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

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/11177>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:18 UTC