23 May
2011
23 May
'11
1:40 p.m.
AMDG On 05/23/2011 05:52 AM, Robert Jones wrote:
Hi All
Is it dangerous to write static Boost.Functions or Boost.Lamda placeholders in a multi-theaded context? I think that might be a really stoopid quesion - I'm just checking!
In C++03, local static anything is dangerous, because the initialization is not guaranteed to be thread safe. It's safe in C++0x and both Boost.Function and Boost.Lambda are safe with parallel reads.
eg,
#include
#include void f( ) { namespace ll = boost::lambda; using boost::function;
typedef std::pair
int_pair; static ll::placeholder1_type x; static function
second = ll::bind( & int_pair::second, x ); }
In Christ, Steven Watanabe