Question

INFO

I'd like to use boost::function to pass callback as parameter, like this way:

void ReadPacket(
        boost::function<void (const boost::system::error_code&, Packet* p)> callback);

and then use it :

ReadPacket(boost::bind(
    &ServerSession::storePacket,
    this,
    _1,
    _2
    ));

After all after a chain of callbacks i call

callback(ec, packet);

PROBLEM

I've just compiled solution in Debug and everything looks OK ...

but in Release I got lots of errors mentioned above

BasicSession.h(30): error C2039: 'function' : is not a member of 'boost'
BasicSession.h(30): error C2061: syntax error : identifier 'function'
BasicSession.h(30): error C2059: syntax error : ')'
BasicSession.h(30): error C2143: syntax error : missing ')' before ';'

I'm confused and dissappointed.

SUGGESTION

I've found that there're different syntax in boost::function. For example boost::function0 or boost::function1. This was made due to VS2010 doesn't support something (I don't know what exactly)

Am I right?

I also need to make this application as portable and cross-platform as possible.

boost 1.47 and VS2010

Was it helpful?

Solution

In case if you have missed it, here is the tutorial on boost function. If you look at the tutorial it will list both the 'preferred' and the 'portable' syntax. Since you want the code to be portable, you might want to choose the latter.

OTHER TIPS

the solution is boost::function4

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top