$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
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)