summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 385709d)
raw | patch | inline | side by side (parent: 385709d)
author | mental <mental@users.sourceforge.net> | |
Fri, 9 Mar 2007 00:32:53 +0000 (00:32 +0000) | ||
committer | mental <mental@users.sourceforge.net> | |
Fri, 9 Mar 2007 00:32:53 +0000 (00:32 +0000) |
src/gc-soft-ptr.h | patch | blob | history |
diff --git a/src/gc-soft-ptr.h b/src/gc-soft-ptr.h
index a055ba38c18342dd8b7d39f4c3210cee1807c267..539eac678553dd212672db4c39136075334627ea 100644 (file)
--- a/src/gc-soft-ptr.h
+++ b/src/gc-soft-ptr.h
template <typename T>
class soft_ptr {
public:
- soft_ptr(T * const &pointer=NULL) : _pointer(pointer) {
- _register();
- }
- soft_ptr(soft_ptr const &other) : _pointer(other._pointer) {
+ soft_ptr(T *pointer=NULL) : _pointer(pointer) {
_register();
}
- operator T *() const { return _pointer; }
- T &operator*() const { return *_pointer; }
- T *operator->() const { return _pointer; }
- T &operator[](int i) const { return _pointer[i]; }
+ operator T *() const { return static_cast<T *>(_pointer); }
+ T &operator*() const { return *static_cast<T *>(_pointer); }
+ T *operator->() const { return static_cast<T *>(_pointer); }
+ T &operator[](int i) const { return static_cast<T *>(_pointer)[i]; }
- soft_ptr &operator=(T * const &pointer) {
+ soft_ptr &operator=(T *pointer) {
_pointer = pointer;
return *this;
}
void _register() {
void *base=Core::base(this);
if (base) {
- Core::general_register_disappearing_link((void **)&_pointer, base);
+ Core::general_register_disappearing_link(&_pointer, base);
}
}
- T *_pointer;
+ void *_pointer;
};
}