class C {
mutable std::mutex _lock;
map<string,string> deep_member;
public:
auto get_big_lump()
{
std::unique_lock<std::mutex> lock(_lock); // establish scope guard
return deep_member; // copy the stuff while it can't be changed on another thread.
}
};
关于保护和返回值复制的保证时间是什么? 在允许(或实际!)优化的情况下,是否会在持有锁时进行复制,或者可以在函数体返回后完成其中的一些操作?