last day (14 days later) » 

12:27 PM
0
A: C++ Boost function callback. How to invoke function as a callback and pass params inside?

seheFirst you have to make it so that a callback can take a parameter: typedef boost::function<void(CommandResult::SharedConst)> callback; Then you need to match that signature in the bind. It looks like you want to leave the result free for binding from within the Scheduler::run() logic, so let's...

 
In your example result is a simple structure with single primitive type field member. When I create callback's type mask typedef boost::function<void(Result::Shared)> callback; and then define member mManagerCallback as a callback type IDE says, that instantiating as unknown structure without a reference.
 
I think your comment is incomplete? Also, just post a complete question with complete code. I made up Result because you didn't include it. You can't really comment on this answer based on the fact that your Result is different...
 
I edit question and include Result)
 
@DenisMakovsky the usual route is to post a new question, because it's bad style to invalidate the existing answer(s). I'll look at it briefly though
I'm having to guess, because nowhere do you show how you construct the CommandResult, but likely you're passing it a "reason" and because the parameter is not const& it doesn't compile. Anyhow, here's a full demo that does work Live On Coliru (C++03) printing: Accepted: cf946fb0-49f3-425a-8235-558d19bf6f8d, 404: 2016-Dec-23 12:18:01
 
can I use not boost shred_ptr with boost function ?
 
12:28 PM
@DenisMakovsky You can. Why not. Function is not related to shared_pointer
Why ask? Now that we've found out that you're using Boost anyways, why change it (Note I removed that suggestion from my answer)
 
It;s very strage. Code in Coliru similar to my, but I have a problem when define callback instance in Scheduler
 
@DenisMakovsky If you make it a SSCCE, I'll look at it.
Most often, reducing it for a SSCCE makes you spot the problem yourself.
 
Code has build succesffully
Strange
Thanks a lot
Your tips were very helpful
Sorry for my broken English)
 
12:44 PM
Your English was fine :) Cheers
 

last day (14 days later) »