Boost C++ Libraries: Ticket #3453: Using bind with Boost.Function won't compile https://svn.boost.org/trac10/ticket/3453 <p> Below codes are copied from sample codes in Boost.Bind documentation at <a href="http://www.boost.org/doc/libs/1_40_0/libs/bind/bind.html#with_boost_function">http://www.boost.org/doc/libs/1_40_0/libs/bind/bind.html#with_boost_function</a>, with a little modification. </p> <p> It compiles in older version (1.30.0) but fails to compile in newer version (1.36.0 or newer) and report following error: </p> <p> \boost/function/function_base.hpp(316) : error C2059: syntax error : '(' </p> <p> \boost/function/function_base.hpp(312) : while compiling class template member function 'void boost::detail::function::functor_manager_common&lt;Functor&gt;::manage_small(const boost::detail::function::function_buffer &amp;,boost::detail::function::function_buffer &amp;,boost::detail::function::functor_manager_operation_type)' </p> <p> I am using MSVC 9.0. Seems there is a bug in the Boost.Function codes. </p> <p> Here are the test codes: </p> <p> class button </p> <p> { </p> <p> public: </p> <blockquote> <p> boost::function&lt;void()&gt; onClick; </p> </blockquote> <p> }; </p> <p> class player </p> <p> { </p> <p> public: </p> <blockquote> <p> void play(){}; </p> </blockquote> <blockquote> <p> void stop(){}; </p> </blockquote> <p> }; </p> <p> button playButton, stopButton; </p> <p> player thePlayer; </p> <p> void connect() </p> <p> { </p> <blockquote> <p> playButton.onClick = boost::bind(&amp;player::play, &amp;thePlayer); </p> </blockquote> <blockquote> <p> stopButton.onClick = boost::bind(&amp;player::stop, &amp;thePlayer); </p> </blockquote> <p> } </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/3453 Trac 1.4.3 Steven Watanabe Tue, 15 Sep 2009 18:09:19 GMT <link>https://svn.boost.org/trac10/ticket/3453#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3453#comment:1</guid> <description> <p> The following compiles for me against both 1.40 and the trunk. </p> <pre class="wiki">#include &lt;boost/function.hpp&gt; #include &lt;boost/bind.hpp&gt; class button { public: boost::function&lt;void()&gt; onClick; }; class player { public: void play(){}; void stop(){}; }; button playButton, stopButton; player thePlayer; void connect() { playButton.onClick = boost::bind(&amp;player::play, &amp;thePlayer); stopButton.onClick = boost::bind(&amp;player::stop, &amp;thePlayer); } </pre><p> Can you post a complete self-contained example (with #includes) that fails? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Steven Watanabe</dc:creator> <pubDate>Tue, 15 Sep 2009 18:21:53 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/3453#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3453#comment:2</guid> <description> <p> My best guess is that new has been #defined. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Thu, 17 Sep 2009 17:03:44 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/3453#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3453#comment:3</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/3453#comment:2" title="Comment 2">steven_watanabe</a>: </p> <blockquote class="citation"> <p> My best guess is that new has been #defined. </p> </blockquote> <p> You are right! new has been #defined in a header file ahead of including boost header file. After I changed their including order, the problem solved. </p> <p> Thanks, you are very helpful! </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Steven Watanabe</dc:creator> <pubDate>Mon, 14 Dec 2009 22:31:23 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/3453#comment:4 https://svn.boost.org/trac10/ticket/3453#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> Ticket