|
Boost Users : |
Subject: [Boost-users] RE : [lambda] for thread bind
From: Eric MALENFANT (Eric.Malenfant_at_[hidden])
Date: 2009-09-10 16:24:00
Boost lzw wrote:
[snip]
> but the lambda version does not compile. Why? Thanks.
> -------------------------------------
> void test_thread(std::string s)
> {
> cout << "string is" << s << endl;
> }
>
> std::string s("I am a string");
> boost::thread inquiry_thread(bind(test_thread, _1)(s) );
>
bind(test_thread, _1) creates a functor expecting one argument. Appending "(s)" right after invokes that functor, passing it s as an argument.
What you want is: bind(&test_thread, s)
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