|
Boost Users : |
From: Rene Rivera (grafik.list_at_[hidden])
Date: 2005-08-29 14:29:47
BRIDGES Dick wrote:
> The documentation gives examples for
> int operator()(int a, int b)...
> bool operator()(long a, long b)...
> that use _1 to represent the first parameter (i.e., 'a').
>
> I'm trying to pass a function object that takes no
> parameters to a boost::thread constructor and cannot
> get it right.
>
> <my_code>
> class Foo {
> void
> operator()() { /* do something */ return; }
> }
>
> int
> main( int argc, char **argv ) {
>
> Foo f;
> boost::thread doit( boost:bind<void>(f,_1)() );
> doit.join();
>
> return 0;
> }</my_code>
Either:
int
main( int argc, char **argv ) {
Foo f;
boost::thread doit( boost:bind(Foo::operator(),&f)() );
doit.join();
return 0;
}
Or:
int
main( int argc, char **argv ) {
Foo f;
boost::thread doit( f );
doit.join();
return 0;
}
Should work.
-- -- Grafik - Don't Assume Anything -- Redshift Software, Inc. - http://redshift-software.com -- rrivera/acm.org - grafik/redshift-software.com -- 102708583/icq - grafikrobot/aim - Grafik/jabber.org
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