I have some (API library, so I can not change the prototype function), which is written as follows:
void FreeContext(Context c);
Now, at some point in my execution, I have a variable Context* local_context;, and that too cannot be changed.
I want to use boost::bindwith a function FreeContext, but I need to get Contextfrom a local variable Context*.
If I write my code as follows, the compiler says that this is “illegal indirection”:
boost::bind(::FreeContext, *_1);
I managed to solve this problem as follows:
template <typename T> T retranslate_parameter(T* t) {
return *t;
}
boost::bind(::FreeContext,
boost::bind(retranslate_parameter<Context>, _1));
But this decision seems to me not very good. Any ideas on how to solve this using something like *_1. Maybe write a little lambda function?