Created
August 29, 2009 16:29
-
-
Save snipsnipsnip/177559 to your computer and use it in GitHub Desktop.
gc_ptr: (not) smart pointer using boehm gc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef GC_PTR_HPP_ | |
#define GC_PTR_HPP_ | |
class gc_cleanup; | |
template <typename T> | |
class gc_ptr : public gc_cleanup | |
{ | |
T *ptr; | |
const P<T> &operator =(T *); | |
public: | |
P(T *t) : ptr(t) {} | |
operator T *() { return ptr; } | |
T *operator ->() { return ptr; } | |
~P() { delete ptr; } | |
}; | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment