diff options
author | Pavel Labath <pavelo@centrum.sk> | 2011-06-14 14:47:32 (GMT) |
---|---|---|
committer | Pavel Labath <pavelo@centrum.sk> | 2011-09-14 17:39:10 (GMT) |
commit | 0a40d1caf3180538d83c7016939d91c7beaf6c2c (patch) | |
tree | a95107a2e15f828410684e10600ff4e9a216fd64 /src/FbTk/RefCount.hh | |
parent | b9e9eb4e44a30204f719c40edd792f35305af932 (diff) | |
download | fluxbox-0a40d1caf3180538d83c7016939d91c7beaf6c2c.zip fluxbox-0a40d1caf3180538d83c7016939d91c7beaf6c2c.tar.bz2 |
Add template copy constructor to FbTk::Refcount
and remove a an "almost" copy constructor (almost, because it takes a non-const reference
parameter) which was useless.
Diffstat (limited to 'src/FbTk/RefCount.hh')
-rw-r--r-- | src/FbTk/RefCount.hh | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/FbTk/RefCount.hh b/src/FbTk/RefCount.hh index 597f847..fe267e3 100644 --- a/src/FbTk/RefCount.hh +++ b/src/FbTk/RefCount.hh | |||
@@ -32,8 +32,9 @@ class RefCount { | |||
32 | public: | 32 | public: |
33 | RefCount(); | 33 | RefCount(); |
34 | explicit RefCount(Pointer *p); | 34 | explicit RefCount(Pointer *p); |
35 | explicit RefCount(RefCount<Pointer> ©); | ||
36 | RefCount(const RefCount<Pointer> ©); | 35 | RefCount(const RefCount<Pointer> ©); |
36 | template<typename Pointer2> | ||
37 | RefCount(const RefCount<Pointer2> ©); | ||
37 | ~RefCount(); | 38 | ~RefCount(); |
38 | RefCount<Pointer> &operator = (const RefCount<Pointer> ©); | 39 | RefCount<Pointer> &operator = (const RefCount<Pointer> ©); |
39 | RefCount<Pointer> &operator = (Pointer *p); | 40 | RefCount<Pointer> &operator = (Pointer *p); |
@@ -50,6 +51,10 @@ private: | |||
50 | void decRefCount(); | 51 | void decRefCount(); |
51 | Pointer *m_data; ///< data holder | 52 | Pointer *m_data; ///< data holder |
52 | unsigned int *m_refcount; ///< holds reference counting | 53 | unsigned int *m_refcount; ///< holds reference counting |
54 | |||
55 | // we need this for the template copy constructor | ||
56 | template<typename Pointer2> | ||
57 | friend class RefCount; | ||
53 | }; | 58 | }; |
54 | 59 | ||
55 | // implementation | 60 | // implementation |
@@ -60,7 +65,8 @@ RefCount<Pointer>::RefCount():m_data(0), m_refcount(new unsigned int(0)) { | |||
60 | } | 65 | } |
61 | 66 | ||
62 | template <typename Pointer> | 67 | template <typename Pointer> |
63 | RefCount<Pointer>::RefCount(RefCount<Pointer> ©): | 68 | template <typename Pointer2> |
69 | RefCount<Pointer>::RefCount(const RefCount<Pointer2> ©): | ||
64 | m_data(copy.m_data), | 70 | m_data(copy.m_data), |
65 | m_refcount(copy.m_refcount) { | 71 | m_refcount(copy.m_refcount) { |
66 | incRefCount(); | 72 | incRefCount(); |