Boost C++ Libraries: Ticket #2742: Why the at_thread_exit cleanup function is const? https://svn.boost.org/trac10/ticket/2742 <p> If I remove the const on operator()() </p> <div class="wiki-code"><div class="code"><pre> <span class="k">struct</span> <span class="n">mycallable1</span> <span class="p">{</span> <span class="kt">void</span> <span class="k">operator</span><span class="p">()()</span> <span class="p">{</span> <span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o">&lt;&lt;</span> <span class="s">&quot;mycallable1&quot;</span> <span class="o">&lt;&lt;</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span> <span class="p">};</span> <span class="p">};</span> <span class="kt">void</span> <span class="nf">my_thread</span><span class="p">()</span> <span class="p">{</span> <span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o">&lt;&lt;</span> <span class="s">&quot;my_thread&quot;</span> <span class="o">&lt;&lt;</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span> <span class="n">mycallable1</span> <span class="n">x</span><span class="p">;</span> <span class="n">boost</span><span class="o">::</span><span class="n">this_thread</span><span class="o">::</span><span class="n">at_thread_exit</span><span class="p">(</span><span class="n">x</span><span class="p">);</span> <span class="p">}</span> </pre></div></div><p> I get the following error: </p> <pre class="wiki">gcc.compile.c++ ..\..\..\bin.v2\libs\interthreads\test\hello_world.test\gcc-4.3.2\debug\target-os-cygwin\threadapi-pthread\threading-multi\hello_world.o ../../../boost/thread/detail/thread.hpp: In member function `void boost::detail::thread_exit_function&lt;F&gt;::operator()() const [with F = mycallable1]': ..\example\hello_world.cpp:52: instantiated from here ../../../boost/thread/detail/thread.hpp:474: error: passing `const mycallable1' as `this' argument of `void mycallable1::operator()()' discards qualifiers </pre><p> Why the cleanup function must be const? </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/2742 Trac 1.4.3 anonymous Thu, 28 May 2009 20:01:13 GMT attachment set https://svn.boost.org/trac10/ticket/2742 https://svn.boost.org/trac10/ticket/2742 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">thread.hpp</span> </li> </ul> Ticket viboes Thu, 28 May 2009 20:03:16 GMT attachment set https://svn.boost.org/trac10/ticket/2742 https://svn.boost.org/trac10/ticket/2742 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">2742.patch</span> </li> </ul> Ticket viboes Thu, 28 May 2009 20:05:23 GMT attachment set https://svn.boost.org/trac10/ticket/2742 https://svn.boost.org/trac10/ticket/2742 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">test_ticket_2742.cpp</span> </li> </ul> Ticket viboes Thu, 28 May 2009 20:06:48 GMT <link>https://svn.boost.org/trac10/ticket/2742#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2742#comment:1</guid> <description> <p> The attached files contains the test showing the bug and a patch solving the issue </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sun, 22 Nov 2009 19:04:34 GMT</pubDate> <title>type changed https://svn.boost.org/trac10/ticket/2742#comment:2 https://svn.boost.org/trac10/ticket/2742#comment:2 <ul> <li><strong>type</strong> <span class="trac-field-old">Bugs</span> → <span class="trac-field-new">Patches</span> </li> </ul> Ticket Anthony Williams Wed, 25 Nov 2009 11:06:18 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/2742#comment:3 https://svn.boost.org/trac10/ticket/2742#comment:3 <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">fixed</span> </li> </ul> <p> Fixed on trunk </p> Ticket