diff options
author | Pavel Labath <pavelo@centrum.sk> | 2011-07-22 15:52:58 (GMT) |
---|---|---|
committer | Pavel Labath <pavelo@centrum.sk> | 2011-09-14 17:39:11 (GMT) |
commit | d21ceb4a235d8f8994390d7bc7611b990e6c0c31 (patch) | |
tree | 909bd768f8b9893e0a425d01ef63e10185bfd3ac /src/FbTk/RefCount.hh | |
parent | 1f34dee9b3ce82a2b9f3578ecb14ad3c59080c46 (diff) | |
download | fluxbox_paul-d21ceb4a235d8f8994390d7bc7611b990e6c0c31.zip fluxbox_paul-d21ceb4a235d8f8994390d7bc7611b990e6c0c31.tar.bz2 |
Remove the assignment operator from a regular pointer to a RefCount
it is too easy too shoot yourself in the foot with it, other smart pointers also don't allow such
assignments. If you do want to assign to a RefCount pointer, use reset().
ps: assignment between two RefCounts remains possible, of course.
Diffstat (limited to 'src/FbTk/RefCount.hh')
-rw-r--r-- | src/FbTk/RefCount.hh | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/FbTk/RefCount.hh b/src/FbTk/RefCount.hh index 2595864..cc8c917 100644 --- a/src/FbTk/RefCount.hh +++ b/src/FbTk/RefCount.hh | |||
@@ -37,11 +37,10 @@ public: | |||
37 | RefCount(const RefCount<Pointer2> ©); | 37 | RefCount(const RefCount<Pointer2> ©); |
38 | ~RefCount(); | 38 | ~RefCount(); |
39 | RefCount<Pointer> &operator = (const RefCount<Pointer> ©); | 39 | RefCount<Pointer> &operator = (const RefCount<Pointer> ©); |
40 | RefCount<Pointer> &operator = (Pointer *p); | ||
41 | Pointer &operator * () const { return *get(); } | 40 | Pointer &operator * () const { return *get(); } |
42 | Pointer *operator -> () const { return get(); } | 41 | Pointer *operator -> () const { return get(); } |
43 | Pointer *get() const { return m_data; } | 42 | Pointer *get() const { return m_data; } |
44 | void reset(Pointer *p) { *this = p; } | 43 | void reset(Pointer *p = 0); |
45 | /// conversion to "bool" | 44 | /// conversion to "bool" |
46 | operator bool_type() const { return m_data ? &RefCount::m_data : 0; } | 45 | operator bool_type() const { return m_data ? &RefCount::m_data : 0; } |
47 | 46 | ||
@@ -100,12 +99,11 @@ RefCount<Pointer> &RefCount<Pointer>::operator = (const RefCount<Pointer> ©) | |||
100 | } | 99 | } |
101 | 100 | ||
102 | template <typename Pointer> | 101 | template <typename Pointer> |
103 | RefCount<Pointer> &RefCount<Pointer>::operator = (Pointer *p) { | 102 | void RefCount<Pointer>::reset(Pointer *p) { |
104 | decRefCount(); | 103 | decRefCount(); |
105 | m_data = p; // set data pointer | 104 | m_data = p; // set data pointer |
106 | m_refcount = new unsigned int(0); // create new counter | 105 | m_refcount = new unsigned int(0); // create new counter |
107 | incRefCount(); | 106 | incRefCount(); |
108 | return *this; | ||
109 | } | 107 | } |
110 | 108 | ||
111 | template <typename Pointer> | 109 | template <typename Pointer> |