借 shared_ptr 实现 copy-on-write(避免死锁,mutex替换rwlock)
书中提到假设有下面代码:MutexLockmutex;std::vectorfoos;voidpost(constFoo&f){MutexLockGuardlock(mutex);foos.push_back(f);}voidtraverse(){MutexLockGuardlock(mutex);for(std::vector::const_iteratorit=foos.begin();it!