Boost logo

Boost Users :

From: Oliver Kowalke (oliver.kowalke_at_[hidden])
Date: 2005-02-04 04:22:42


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

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net