首页 | 本学科首页   官方微博 | 高级检索  
     


The implementation of generic smart pointers for advanced defensive programming
Authors:Anthony Savidis
Abstract:Smart pointers denote a well‐known technique for collective resource ownership, e.g. sharing dynamic object instances, while usually supporting automatic garbage collection based on reference counting. The original method has been retargeted to serve as a generic defensive programming method for ‘exhaustive tracking’ of erroneous pointer use in C++. Automatic bug tracking is supported in a unified manner both for pointers to heap memory, i.e. free storage, as well as for pointers to stack or global memory, i.e. auto or static storage. Overall, the presented technique (a) offers a simple contract for memory allocation and use; (b) supports type and indirection depth genericity; (c) implements most operators supported for built‐in pointers with embedded bug defense; (d) offers an alternative way of employing a garbage collection facility for memory leak detection; and (e) provides an appropriate collection of utility macros, through which defensive pointers should be used, with an alternative version re‐targeted to normal native pointers. Copyright © 2004 John Wiley & Sons, Ltd.
Keywords:smart pointers  defensive programming  garbage collection  memory management  recursive meta‐programming
设为首页 | 免责声明 | 关于勤云 | 加入收藏

Copyright©北京勤云科技发展有限公司  京ICP备09084417号