Commit 7d0e9359 authored by daniel_e's avatar daniel_e
Browse files

(SharedPtr<>::swap): Implement.

parent e1ea3914
2003-01-01 Daniel Elstner <daniel.elstner@gmx.net>
* src/sharedptr.h (SharedPtr<>::swap): Implement.
2003-01-01 Daniel Elstner <daniel.elstner@gmx.net>
* src/mainwindow.cc (on_hide): For safety, transfer ownership of
......
......@@ -85,6 +85,8 @@ public:
template <class U> inline SharedPtr(const SharedPtr<U>& other);
template <class U> inline SharedPtr<T>& operator=(const SharedPtr<U>& other);
inline void swap(SharedPtr<T>& other);
inline void reset(T* ptr = 0); // obtains reference
inline T* get() const;
......@@ -124,6 +126,12 @@ SharedPtr<T>::SharedPtr(T* ptr)
// on purpose -- defining them before they're first used allows for maximum
// inlining.
template <class T> inline
void SharedPtr<T>::swap(SharedPtr<T>& other)
{
std::swap(ptr_, other.ptr_);
}
template <class T> inline
void SharedPtr<T>::reset(T* ptr)
{
......@@ -193,6 +201,12 @@ SharedPtr<T>::operator const void*() const
}
template <class T> inline
void swap(SharedPtr<T>& lhs, SharedPtr<T>& rhs)
{
lhs.swap(rhs);
}
template <class T, class U> inline
SharedPtr<T> shared_static_cast(const SharedPtr<U>& other)
{
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment