Opened 13 years ago
Closed 13 years ago
#3453 closed Bugs (invalid)
Using bind with Boost.Function won't compile
Reported by: | Owned by: | Douglas Gregor | |
---|---|---|---|
Milestone: | Boost 1.41.0 | Component: | function |
Version: | Boost 1.40.0 | Severity: | Showstopper |
Keywords: | Cc: |
Description
Below codes are copied from sample codes in Boost.Bind documentation at http://www.boost.org/doc/libs/1_40_0/libs/bind/bind.html#with_boost_function, with a little modification.
It compiles in older version (1.30.0) but fails to compile in newer version (1.36.0 or newer) and report following error:
\boost/function/function_base.hpp(316) : error C2059: syntax error : '('
\boost/function/function_base.hpp(312) : while compiling class template member function 'void boost::detail::function::functor_manager_common<Functor>::manage_small(const boost::detail::function::function_buffer &,boost::detail::function::function_buffer &,boost::detail::function::functor_manager_operation_type)'
I am using MSVC 9.0. Seems there is a bug in the Boost.Function codes.
Here are the test codes:
class button
{
public:
boost::function<void()> onClick;
};
class player
{
public:
void play(){};
void stop(){};
};
button playButton, stopButton;
player thePlayer;
void connect()
{
playButton.onClick = boost::bind(&player::play, &thePlayer);
stopButton.onClick = boost::bind(&player::stop, &thePlayer);
}
Change History (4)
comment:1 by , 13 years ago
comment:3 by , 13 years ago
Replying to steven_watanabe:
My best guess is that new has been #defined.
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.
Thanks, you are very helpful!
comment:4 by , 13 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
The following compiles for me against both 1.40 and the trunk.
Can you post a complete self-contained example (with #includes) that fails?