3 This file is part of gldbg
4 Copyright © 2009 Mikko Rasa, Mikkosoft Productions
5 Distributed under the GPL
8 #ifndef AUTOCONSTPTR_H_
9 #define AUTOCONSTPTR_H_
12 A smart pointer that only provides non-const access to the contents if the
13 pointer itself is non-const.
22 AutoConstPtr(T *p): ptr(p) { }
23 AutoConstPtr &operator=(T *p) { ptr = p; return *this; }
24 T *operator->() { return ptr; }
25 const T *operator->() const { return ptr; }
26 operator T *() { return ptr; }
27 operator const T *() const { return ptr; }