
AMDG Korcan Hussein wrote:
Sorry about the poor title, it is difficult for me to explain the problem without code so here is a really simple example of what i'm trying to achieve but fails to compile with Boost.Bind:
#include <boost/bind.hpp>
struct FunFn {
typedef void result_type; template < typename Fun > void operator()(Fun fn) const { fn(); }
} const Fn;
void g() { std::cout << "hello\n"; }
int main() { using namespace boost;
bind(Fn, bind(Fn, bind(Fn, bind(Fn, ... bind(Fn, g))();
}
This creates a function object that executes: Fn(Fn(Fn(g()))) Since the inner functions return void, of course it fails.
I get type deduction errors, however i have found workaround using Boost.Function for the time being:
#include <boost/function.hpp>
... boost::function< void () > fnN = bind(Fn, g), fnN-1 = bind(Fn, fnN), ..., fn1 = bind(Fn, fn2), fn = bind(Fn, fn1);
bind(Fn, fn)();
In Christ, Steven Watanabe