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.
Pavel Labath pavelo@centrum.sk
1 files changed,
8 insertions(+),
2 deletions(-)
jump to
M
src/FbTk/RefCount.hh
→
src/FbTk/RefCount.hh
@@ -32,8 +32,9 @@
public: RefCount(); explicit RefCount(Pointer *p); - explicit RefCount(RefCount<Pointer> ©); RefCount(const RefCount<Pointer> ©); + template<typename Pointer2> + RefCount(const RefCount<Pointer2> ©); ~RefCount(); RefCount<Pointer> &operator = (const RefCount<Pointer> ©); RefCount<Pointer> &operator = (Pointer *p);@@ -50,6 +51,10 @@ /// decrease reference count
void decRefCount(); Pointer *m_data; ///< data holder unsigned int *m_refcount; ///< holds reference counting + + // we need this for the template copy constructor + template<typename Pointer2> + friend class RefCount; }; // implementation@@ -60,7 +65,8 @@ incRefCount(); // it really counts how many things are storing m_refcount
} template <typename Pointer> -RefCount<Pointer>::RefCount(RefCount<Pointer> ©): +template <typename Pointer2> +RefCount<Pointer>::RefCount(const RefCount<Pointer2> ©): m_data(copy.m_data), m_refcount(copy.m_refcount) { incRefCount();