4 Feb
2005
4 Feb
'05
9:22 a.m.
Hi, is it possible to use boost::function as drop-in replacment for ordinary function pointers - or are there some other solutions? I can't get the code below to work. thx and best regards, Oliver typedef void (*FunctionPointer) ( int); void my_fun( int i) { std::cout << i << std::endl; } class MyFun { public: void operator()( int i) { std::cout << i << std::endl; } }; class Test { public: void f( FunctionPointer fp) { fp( 1); } }; void main() { Test tst; MyFun mf; boost::function< void(int) > f; f = boost::ref( mf); // tst.f( my_fun); // works tst.f( f); // ??? - doesn't compile } -- DSL Komplett von GMX +++ Superg�nstig und stressfrei einsteigen! AKTION "Kein Einrichtungspreis" nutzen: http://www.gmx.net/de/go/dsl