forked from Bananymous/banan-os
BAN: UniqPtr can now be constructed from other convertible UniqPtr
This commit is contained in:
parent
e57c1fc9fc
commit
6feb8a99d2
|
@ -14,7 +14,8 @@ namespace BAN
|
||||||
public:
|
public:
|
||||||
UniqPtr() = default;
|
UniqPtr() = default;
|
||||||
|
|
||||||
UniqPtr(UniqPtr&& other)
|
template<typename U>
|
||||||
|
UniqPtr(UniqPtr<U>&& other)
|
||||||
{
|
{
|
||||||
m_pointer = other.m_pointer;
|
m_pointer = other.m_pointer;
|
||||||
other.m_pointer = nullptr;
|
other.m_pointer = nullptr;
|
||||||
|
@ -42,8 +43,10 @@ namespace BAN
|
||||||
return uniq;
|
return uniq;
|
||||||
}
|
}
|
||||||
|
|
||||||
UniqPtr& operator=(UniqPtr&& other)
|
template<typename U>
|
||||||
|
UniqPtr& operator=(UniqPtr<U>&& other)
|
||||||
{
|
{
|
||||||
|
clear();
|
||||||
m_pointer = other.m_pointer;
|
m_pointer = other.m_pointer;
|
||||||
other.m_pointer = nullptr;
|
other.m_pointer = nullptr;
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -87,6 +90,9 @@ namespace BAN
|
||||||
|
|
||||||
private:
|
private:
|
||||||
T* m_pointer = nullptr;
|
T* m_pointer = nullptr;
|
||||||
|
|
||||||
|
template<typename U>
|
||||||
|
friend class UniqPtr;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue