Ray's playground

 

2011年3月30日

Item29: Strive for exception-safe code.(Effective C++)

摘要: Exception-safe functions leak no resources and allow no data structures to become corrupted, even when exceptions are thrown. Such functions offer the basic, strong, or nothrow guarantees. The strong guarantee can often be implemented via copy-and-swap, but the strong guarantee is not practical for. 阅读全文

posted @ 2011-03-30 23:33 Ray Z 阅读(291) 评论(0) 推荐(0) 编辑

Item 28: Avoid returning "handles" to object internals.(Effective C++)

摘要: Avoid returning handles (references, pointers, or iterators) to object internals. It increases encapsulation, helps const member functions act const, and minimizes the creation of dangling handles. 阅读全文

posted @ 2011-03-30 12:01 Ray Z 阅读(171) 评论(0) 推荐(0) 编辑

Item 27: Minimize casting.(Effective C++)

摘要: Avoid casts whenever practical, especially dynamic_casts in performance-sensitive code. If a design requires casting, try to develop a cast-free alternative. When casting is necessary, try to hide it inside a function. Clients can then call the function instead of putting casts in their own code. P. 阅读全文

posted @ 2011-03-30 11:36 Ray Z 阅读(184) 评论(0) 推荐(0) 编辑

导航