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.
This commit is contained in:
parent
b9e9eb4e44
commit
0a40d1caf3
1 changed files with 8 additions and 2 deletions
|
@ -32,8 +32,9 @@ class RefCount {
|
|||
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 @@ private:
|
|||
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 @@ RefCount<Pointer>::RefCount():m_data(0), m_refcount(new unsigned int(0)) {
|
|||
}
|
||||
|
||||
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();
|
||||
|
|
Loading…
Reference in a new issue