Boost C++ Libraries: Ticket #1076: compile error: disconnecting struct with operator()() doesn't work in VS2005 SP1 https://svn.boost.org/trac10/ticket/1076 <p> According to <a href="http://www.boost.org/doc/html/signals/tutorial.html#id1626102">http://www.boost.org/doc/html/signals/tutorial.html#id1626102</a> it should be possible to connect a signal to operator()() in a struct. While connecting works indeed disconnecting doesn't (in VS2005 SP1). The compile error VS2005 reports is: </p> <p> C2678: binary '==' : no operator found which takes a left-hand operand of type 'const event_handler' (or there is no acceptable conversion) </p> <p> There has been a discussion on the mailing list already - see <a class="ext-link" href="http://thread.gmane.org/gmane.comp.lib.boost.user/27997/focus=28629"><span class="icon">​</span>http://thread.gmane.org/gmane.comp.lib.boost.user/27997/focus=28629</a> </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/1076 Trac 1.4.3 boris@… Wed, 04 Jul 2007 04:49:20 GMT attachment set https://svn.boost.org/trac10/ticket/1076 https://svn.boost.org/trac10/ticket/1076 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">testcase.cpp</span> </li> </ul> Ticket Eric Niebler Wed, 11 Jul 2007 01:51:44 GMT owner set https://svn.boost.org/trac10/ticket/1076#comment:1 https://svn.boost.org/trac10/ticket/1076#comment:1 <ul> <li><strong>owner</strong> set to <span class="trac-author">doug_gregor</span> </li> </ul> Ticket boris@… Thu, 24 Apr 2008 15:13:51 GMT <link>https://svn.boost.org/trac10/ticket/1076#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/1076#comment:2</guid> <description> <p> The problem can also be reproduced with VC++ 9.0. Upgrading the compiler won't help unfortunately. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Douglas Gregor</dc:creator> <pubDate>Tue, 29 Apr 2008 18:30:42 GMT</pubDate> <title>owner changed https://svn.boost.org/trac10/ticket/1076#comment:3 https://svn.boost.org/trac10/ticket/1076#comment:3 <ul> <li><strong>owner</strong> changed from <span class="trac-author">doug_gregor</span> to <span class="trac-author">Douglas Gregor</span> </li> </ul> Ticket anonymous Mon, 30 Nov 2009 14:19:54 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/1076#comment:4 https://svn.boost.org/trac10/ticket/1076#comment:4 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">invalid</span> </li> </ul> <p> I think you need an equality comparison here - otherwise, how will the compiler know which slot to disconnect? </p> <pre class="wiki">struct event_handler { void operator()() {} bool operator == ( const event_handler &amp;rhs ) { return true; } }; </pre><p> I'll see about getting the documentation updated, too. </p> Ticket Marshall Clow Mon, 30 Nov 2009 14:22:20 GMT <link>https://svn.boost.org/trac10/ticket/1076#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/1076#comment:5</guid> <description> <p> I was the one who closed the bug. </p> </description> <category>Ticket</category> </item> <item> <author>Martin Pyle <MartinNvPyle@…></author> <pubDate>Wed, 21 Apr 2010 16:22:38 GMT</pubDate> <title>status changed; cc set; resolution deleted https://svn.boost.org/trac10/ticket/1076#comment:6 https://svn.boost.org/trac10/ticket/1076#comment:6 <ul> <li><strong>cc</strong> <span class="trac-author">MartinNvPyle@…</span> added </li> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">invalid</span> </li> </ul> <p> In: </p> <blockquote> <p> <a class="ext-link" href="http://lists.boost.org/boost-users/2007/07/29153.php"><span class="icon">​</span>http://lists.boost.org/boost-users/2007/07/29153.php</a> </p> </blockquote> <p> Boris showed some error output. That seems to show his original problem with signal::disconnect was while using boost::function, not a hand crafted struct/functor as is shown here. I think he may have over simplified his example. </p> <p> I have the same problem Boris had. Using VS2005, and a boost::function object I get operator==() cant be found errors when calling signal::disconnect. Of course, boost::function does have an operator==(). </p> <p> Here's an example: </p> <pre class="wiki">#include &lt;boost/signal.hpp&gt; #include &lt;boost/function.hpp&gt; void foo() { } void TrySignalDisconnect() { typedef boost::function&lt;void()&gt; MyFunctorType; MyFunctorType myFunctorFoo(&amp;foo); assert( &amp;foo == myFunctorFoo ); //compiles! //assert( myFunctorFoo == myFunctorFoo) ); //will NOT compile boost::signal&lt;void()&gt; sig; sig.connect(myFunctorFoo); //sig.disconnect(myFunctorFoo); //will NOT compile -- same reason } </pre><p> To me it looks like boost::function will compare with a raw function pointer, but not another boost::function ? </p> <p> I hope this isn't bending the meaning of this bug too far. I'm using boost 1.35. </p> Ticket bschaeling Wed, 21 Apr 2010 16:39:19 GMT <link>https://svn.boost.org/trac10/ticket/1076#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/1076#comment:7</guid> <description> <p> It's such a long time ago that I reported the bug that I don't remember all the details anymore. However I think your code fails because comparing boost::function objects with == and != isn't supported - see <a href="http://www.boost.org/doc/libs/1_42_0/doc/html/function/faq.html#id877361">http://www.boost.org/doc/libs/1_42_0/doc/html/function/faq.html#id877361</a>. </p> </description> <category>Ticket</category> </item> <item> <author>Martin Pyle <MartinNvPyle@…></author> <pubDate>Thu, 22 Apr 2010 09:19:20 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/1076#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/1076#comment:8</guid> <description> <p> Thanks for the info Boris. Yes that seems to be highly relevant. I now see that lack of <code> myFunctorFoo == myFunctorFoo </code> support (in the above example) follows from type-erasure, plus no compile time type-trait for has operator==(T,T). </p> <p> On the off chance; I don't suppose you can make sense of the (to me) cryptic statement at the end of that FAQ item: "The Signals library has a way around this" ? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Marshall Clow</dc:creator> <pubDate>Tue, 18 Jun 2013 16:58:34 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/1076#comment:9 https://svn.boost.org/trac10/ticket/1076#comment:9 <ul> <li><strong>status</strong> <span class="trac-field-old">reopened</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">wontfix</span> </li> </ul> <p> Boost.Signals is being deprecated. Please transition to Boost.Signals2 </p> Ticket