Boost C++ Libraries: Ticket #11177: signals2 does not allow reference return values for a slot https://svn.boost.org/trac10/ticket/11177 <p> As can easily be tested it is not possible to declare a slot with a reference as a return value: </p> <div class="wiki-code"><div class="code"><pre><span class="cp">#include</span> <span class="cpf">&quot;boost\signals2.hpp&quot;</span><span class="cp"></span> <span class="kt">void</span> <span class="nf">f</span><span class="p">()</span> <span class="p">{</span> <span class="n">boost</span><span class="o">::</span><span class="n">signals2</span><span class="o">::</span><span class="n">signal</span><span class="o">&lt;</span><span class="kt">int</span><span class="o">*</span> <span class="p">()</span><span class="o">&gt;</span> <span class="n">pTest</span><span class="p">;</span> <span class="n">boost</span><span class="o">::</span><span class="n">signals2</span><span class="o">::</span><span class="n">signal</span><span class="o">&lt;</span><span class="kt">int</span><span class="o">&amp;</span> <span class="p">()</span><span class="o">&gt;</span> <span class="n">rTest</span><span class="p">;</span> <span class="kt">int</span><span class="o">*</span> <span class="n">p</span> <span class="o">=</span> <span class="o">*</span><span class="n">pTest</span><span class="p">();</span> <span class="c1">// OK</span> <span class="c1">//int&amp; r = *rTest(); // C2528 on Visual Studio</span> <span class="p">}</span> </pre></div></div><p> 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. </p> <p> 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)? </p> <p> 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? </p> <p> Thx </p> <p> Peter </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11177 Trac 1.4.3 Frank Mori Hess Thu, 09 Apr 2015 19:44:02 GMT status changed https://svn.boost.org/trac10/ticket/11177#comment:1 https://svn.boost.org/trac10/ticket/11177#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> <p> Should be fixed in the development branch now. </p> Ticket Frank Mori Hess Sat, 25 Apr 2015 17:16:23 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/11177#comment:2 https://svn.boost.org/trac10/ticket/11177#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> Ticket