Skip to content

Instantly share code, notes, and snippets.

@snipsnipsnip
Created August 29, 2009 16:29
Show Gist options
  • Save snipsnipsnip/177559 to your computer and use it in GitHub Desktop.
Save snipsnipsnip/177559 to your computer and use it in GitHub Desktop.
gc_ptr: (not) smart pointer using boehm gc
#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