Copy-on-write(COW) 是计算机程序设计中的一种优化策略。The fundamental idea is that if multiple callers ask for resources which are initially indistinguishable, you can give them pointers to the same resource. This fiction can be maintained until a caller tries to modify its "copy" of the resource, at which point a true private copy is created to prevent the changes becoming visible to everyone else. All of this happens transparently to the callers. The primary advantage is that if a caller never makes any modifications, no private copy need ever be created.
STL中的string的实现就用到了copy on write策略。String is a reference counted, copy on write string class




















