Here is a code sample:
class A {
boost::mutex a_mutex;
boost::shared_ptr<int> a;
boost::shared_ptr<int> clone_a(void) {
boost::lock_guard<boost::mutex> lock(a_mutex);
return a;
}
};
The suggestion is that the boost::shared_ptr
copy constructor call on A::a
will precede the boost::lock_guard
destructor call despite of the compiler optimizations.
So, is it safe to call A::clone_a()
?